Main Page   Modules   Data Structures   File List   Data Fields   Examples  

The memory manglement library interface.


Data Structures

struct  _core_memory_sections
 Core file virtual-memory segments. More...

struct  _mem_ctx
 memgrep context. More...

struct  _mem_ctx_core_data
 Core file information. More...

struct  _memgrep_functions
 Medium-independant function table. More...

struct  _memgrep_result
 The result of a given operation. More...

struct  _memgrep_result_row
 Result row base structure. More...

struct  _memgrep_result_row_dump
 Row for memory dump results. More...

struct  _memgrep_result_row_heap
 Row for heap enumeration results. More...

struct  _memgrep_result_row_replace
 Row for replace reuslts. More...

struct  _memgrep_result_row_search
 Row for search results. More...

struct  _process_section_addrs
 Section addresses. More...


Defines

#define MEMGREP_CMD_INITIALIZE   0x00000001
#define MEMGREP_CMD_DEINITIALIZE   0x00000002
#define MEMGREP_CMD_SET   0x00000003
#define MEMGREP_CMD_GET   0x00000004
#define MEMGREP_CMD_POPULATE   0x00000005
#define MEMGREP_CMD_SEARCH   0x00000006
#define MEMGREP_CMD_REPLACE   0x00000007
#define MEMGREP_CMD_SEARCHREPLACE   0x00000008
#define MEMGREP_CMD_DUMP   0x00000009
#define MEMGREP_CMD_LISTSEGMENTS   0x0000000A
#define MEMGREP_CMD_DESTROYRESULT   0x0000000B
#define MEMGREP_CMD_HEAPENUMERATE   0x0000000C
#define MEMGREP_PARAM_FLAGS   0x00000001
#define MEMGREP_PARAM_LENGTH   0x00000002
#define MEMGREP_PARAM_PADDING   0x00000003
#define MEMGREP_PARAM_DUMPFORMAT   0x00000004
#define MEMGREP_RESULT_TYPE_SEARCH   0x00000001
#define MEMGREP_RESULT_TYPE_REPLACE   0x00000002
#define MEMGREP_RESULT_TYPE_DUMP   0x00000003
#define MEMGREP_RESULT_TYPE_HEAP   0x00000004
#define MEMGREP_FLAG_VERBOSE   (1 << 0)
#define MEMGREP_FLAG_PROMPT   (1 << 1)
#define MEMGREP_FLAG_DUMPCLEAN   (1 << 2)

Typedefs

typedef _process_section_addrs PROCESS_SECTION_ADDRS
 Section addresses. More...

typedef _core_memory_sections CORE_MEMORY_SECTIONS
 Core file virtual-memory segments. More...

typedef _mem_ctx_core_data MEM_CTX_CORE_DATA
 Core file information. More...

typedef _memgrep_functions MEMGREP_FUNCTIONS
 Medium-independant function table. More...

typedef _memgrep_result_row MEMGREP_RESULT_ROW
 Result row base structure. More...

typedef _memgrep_result MEMGREP_RESULT
 The result of a given operation. More...

typedef _memgrep_result_row_search MEMGREP_RESULT_ROW_SEARCH
 Row for search results. More...

typedef _memgrep_result_row_heap MEMGREP_RESULT_ROW_HEAP
 Row for heap enumeration results. More...

typedef _memgrep_result_row_replace MEMGREP_RESULT_ROW_REPLACE
 Row for replace reuslts. More...

typedef _memgrep_result_row_dump MEMGREP_RESULT_ROW_DUMP
 Row for memory dump results. More...

typedef _mem_ctx MEM_CTX
 memgrep context. More...


Enumerations

enum  MemoryMedium { MEMORY_MEDIUM_UNKNOWN = 0, MEMORY_MEDIUM_PID = 1, MEMORY_MEDIUM_CORE = 2 }
 memory access mediums. More...

enum  MemoryDumpFormat {
  MEMORY_DUMP_FORMAT_HEXINT = 0, MEMORY_DUMP_FORMAT_HEXSHORT = 1, MEMORY_DUMP_FORMAT_HEXBYTE = 2, MEMORY_DUMP_FORMAT_DECINT = 3,
  MEMORY_DUMP_FORMAT_DECSHORT = 4, MEMORY_DUMP_FORMAT_DECBYTE = 5, MEMORY_DUMP_FORMAT_PRINTABLE = 6
}
 memory dumping format. More...


Functions

unsigned long memgrep (MEM_CTX *ctx, unsigned long cmd, MEMGREP_RESULT *result, unsigned long param, unsigned long data)
unsigned long memgrep_initialize (MEM_CTX *ctx, enum MemoryMedium medium, void *data)
unsigned long memgrep_deinitialize (MEM_CTX *ctx)
unsigned long memgrep_set (MEM_CTX *ctx, unsigned long param, unsigned long data)
unsigned long memgrep_get (MEM_CTX *ctx, unsigned long param)
unsigned long memgrep_populate_string (MEM_CTX *ctx, const char *addresses)
unsigned long memgrep_populate_array (MEM_CTX *ctx, unsigned long *array, unsigned long elements)
unsigned long memgrep_search (MEM_CTX *ctx, MEMGREP_RESULT *result, const char *searchPhrase)
unsigned long memgrep_replace (MEM_CTX *ctx, MEMGREP_RESULT *result, const char *replacePhrase)
unsigned long memgrep_searchreplace (MEM_CTX *ctx, MEMGREP_RESULT *result, const char *searchPhrase, const char *replacePhrase)
unsigned long memgrep_dump (MEM_CTX *ctx, MEMGREP_RESULT *result)
unsigned long memgrep_listSegments (MEM_CTX *ctx)
unsigned long memgrep_destroy (MEM_CTX *ctx, MEMGREP_RESULT *result)
unsigned long memgrep_heapenumerate (MEM_CTX *ctx, MEMGREP_RESULT *result, unsigned long minSize)

Detailed Description

The memory manglement library interface.

Define Documentation

#define MEMGREP_CMD_DEINITIALIZE   0x00000002
 

Deinitialize from a given medium.

Deinitializes a given memgrep context. This will free up any resources that had incurred over the time of its use.

#define MEMGREP_CMD_DESTROYRESULT   0x0000000B
 

Destroy the contents of a result that was handed back by a command

The 'param' argument should be a pointer to a result structure.

The 'data' argument is undefined and should be 0.

#define MEMGREP_CMD_DUMP   0x00000009
 

Dump memory for the addresses specified in MEMGREP_CMD_POPULATE.

No parameters are required.

Results are optionally returned in the 'result' argument if it is not null of type MEMGREP_RESULT_TYPE_DUMP.

#define MEMGREP_CMD_GET   0x00000004
 

Get parameters that have been set on a context.

The 'param' argument can be one of the following:

  • MEMGREP_PARAM_FLAGS The flags the context is using will be returned.
  • MEMGREP_PARAM_LENGTH The length associated with dumping/searching will be returned.
  • MEMGREP_PARAM_PADDING The padding associated with dumping will be returned.

#define MEMGREP_CMD_HEAPENUMERATE   0x0000000C
 

Enumerate the heap of a running process

The 'param' argument is the minimize size of the heap unit, or 0.

The 'data' argument is undefined and should be 0.

#define MEMGREP_CMD_INITIALIZE   0x00000001
 

Initialize from a given medium.

Initializes a given memgrep context to a given medium. The 'param' argument should be one of the enumerations in the MemoryMedium enum. The 'data' argument should be the arbitrary value associated with the medium. For MEMORY_MEDIUM_PID it will be the process id. For MEMORY_MEDIUM_CORE it will be the core file.

#define MEMGREP_CMD_LISTSEGMENTS   0x0000000A
 

List all the segments of a given medium such as rodata, stack, bss, etc.

No parameters are required.

#define MEMGREP_CMD_POPULATE   0x00000005
 

Populate the address array from supplied address(es).

The 'param' argument can be one of the following:

  • A string If the param argument is a string it should have addresses formatted with each address being seperated by commas. Addresses can be specified in hex as well as in the form of a keyword such as: bss, stack, rodata, data, all. The 'data' parameter should be set to 0.
  • An array If the param argument is an array it should be an array of unsigned long's which hold the addresses that are to be used. The 'data' argument should have the number of elements the array contains.

#define MEMGREP_CMD_REPLACE   0x00000007
 

Replace memory with the specified data at the addresses specified by MEMGREP_CMD_POPULATE.

The 'param' argument is used in conjunction with the replace criteria. It can be in the following format:

  • s,example This will replace for the string 'example' in the addresses specified in MEMGREP_CMD_POPULATE
  • i,47 This will replace for the integer 47 in the addresses specified in MEMGREP_CMD_POPULATE
  • x,656667 This will replace for the hex \x65\x66\x67 in the addresses specified in MEMGREP_CMD_POPULATE.
The 'data' argument is undefined and should be set to 0.

Results are optionally returned in the 'result' argument if it is not null of type MEMGREP_RESULT_TYPE_SEARCH.

#define MEMGREP_CMD_SEARCH   0x00000006
 

Search for a given criteria in the addresses specified by MEMGREP_CMD_POPULATE.

The 'param' argument is used in conjunction with the search criteria. It can be in the following format:

  • s,example This will search for the string 'example' in the addresses specified in MEMGREP_CMD_POPULATE
  • i,47 This will search for the integer 47 in the addresses specified in MEMGREP_CMD_POPULATE
  • x,656667 This will search for the hex \x65\x66\x67 in the addresses specified in MEMGREP_CMD_POPULATE.
The 'data' argument is undefined and should be set to 0.

#define MEMGREP_CMD_SEARCHREPLACE   0x00000008
 

Search and replace memory that matches the criteria for the addresses specified by MEMGREP_CMD_POUPLATE.

The 'param' argument is used in conjunction with the search criteria. It can be in the following format:

  • s,example This will search for the string 'example' in the addresses specified in MEMGREP_CMD_POPULATE
  • i,47 This will search for the integer 47 in the addresses specified in MEMGREP_CMD_POPULATE
  • x,656667 This will search for the hex \x65\x66\x67 in the addresses specified in MEMGREP_CMD_POPULATE.
The 'data' argument is used in conjunction with the replace criteria. It can be in the following format:

  • s,example This will replace for the string 'example' in the addresses that match the search criteria.
  • i,47 This will replace for the integer 47 in the addresses that match the search criteria.
  • x,656667 This will replace for the hex \x65\x66\x67 in the addresses that match the search criteria.
Results are optionally returned in the 'result' argument if it is not null of type MEMGREP_RESULT_TYPE_REPLACE.

#define MEMGREP_CMD_SET   0x00000003
 

Set parameters on a context.

The 'param' argument can be one of the following:

  • MEMGREP_PARAM_FLAGS The data argument should be set to the flags that are to be enabled on the context.
  • MEMGREP_PARAM_LENGTH The data argument should be set to the length that is to be used when dumping/searching.
  • MEMGREP_PARAM_PADDING The data argument should be set to the length that is to be used with padding.

#define MEMGREP_FLAG_DUMPCLEAN   (1 << 2)
 

Flag used to enable output of dumping memory in a clear-text format rather than hex.

#define MEMGREP_FLAG_PROMPT   (1 << 1)
 

Flag used to enable prompting before replacing memory.

#define MEMGREP_FLAG_VERBOSE   (1 << 0)
 

Flag used to enable verbose output when performing actions.

#define MEMGREP_PARAM_DUMPFORMAT   0x00000004
 

Specifies that the data parameter will be the format to use when dumping.

#define MEMGREP_PARAM_FLAGS   0x00000001
 

Specifies that the data parameter will be flags when used in conjunction with MEMGREP_CMD_SET.

#define MEMGREP_PARAM_LENGTH   0x00000002
 

Specifies that the data parameter will be the length when used in conjunction with MEMGREP_CMD_SET.

#define MEMGREP_PARAM_PADDING   0x00000003
 

Specifies that the data parameter will be dump padding size when used in conjunction with MEMGREP_CMD_SET.

#define MEMGREP_RESULT_TYPE_DUMP   0x00000003
 

The derived instance of this row is a MEMGREP_RESULT_ROW_DUMP and should be cast as such.

#define MEMGREP_RESULT_TYPE_HEAP   0x00000004
 

The derived instance of this row is a MEMGREP_RESULT_ROW_HEAP and should be cast as such.

#define MEMGREP_RESULT_TYPE_REPLACE   0x00000002
 

The derived instance of this row is a MEMGREP_RESULT_ROW_REPLACE and should be cast as such.

#define MEMGREP_RESULT_TYPE_SEARCH   0x00000001
 

The derived instance of this row is a MEMGREP_RESULT_ROW_SEARCH and should be cast as such.


Typedef Documentation

typedef struct _core_memory_sections CORE_MEMORY_SECTIONS
 

Core file virtual-memory segments.

Holds virtual memory segments of a core file as well as their length.

typedef struct _mem_ctx MEM_CTX
 

memgrep context.

The memgrep context.

typedef struct _mem_ctx_core_data MEM_CTX_CORE_DATA
 

Core file information.

Extended data structure holding information about a core file.

typedef struct _memgrep_functions MEMGREP_FUNCTIONS
 

Medium-independant function table.

The medium-independant function table used internally by memgrep.

typedef struct _memgrep_result MEMGREP_RESULT
 

The result of a given operation.

The result from a given operation, including any rows that were returned.

typedef struct _memgrep_result_row MEMGREP_RESULT_ROW
 

Result row base structure.

The base for all rows in a result

typedef struct _memgrep_result_row_dump MEMGREP_RESULT_ROW_DUMP
 

Row for memory dump results.

Used in association with MEMGREP_CMD_DUMP

typedef struct _memgrep_result_row_heap MEMGREP_RESULT_ROW_HEAP
 

Row for heap enumeration results.

Used in association with MEMGREP_CMD_HEAPENUMERATE

typedef struct _memgrep_result_row_replace MEMGREP_RESULT_ROW_REPLACE
 

Row for replace reuslts.

Used in association MEMGREP_CMD_SEARCHREPLACE and MEMGREP_CMD_REPLACE

typedef struct _memgrep_result_row_search MEMGREP_RESULT_ROW_SEARCH
 

Row for search results.

Used in association with MEMGREP_CMD_SEARCH.

typedef struct _process_section_addrs PROCESS_SECTION_ADDRS
 

Section addresses.

Holds the addresses that signify the start of a given logical section.


Enumeration Type Documentation

enum MemoryDumpFormat
 

memory dumping format.

The format to use when dumping memory

Enumeration values:
MEMORY_DUMP_FORMAT_HEXINT  Dump as hex integers (0xabcdef00)
MEMORY_DUMP_FORMAT_HEXSHORT  Dump as hex shorts (0xabcd)
MEMORY_DUMP_FORMAT_HEXBYTE  Dump as hex characters (0xab)
MEMORY_DUMP_FORMAT_DECINT  Dump as decimal integers (1234)
MEMORY_DUMP_FORMAT_DECSHORT  Dump as decimal shorts (65535)
MEMORY_DUMP_FORMAT_DECBYTE  Dump as decimal characters (127)
MEMORY_DUMP_FORMAT_PRINTABLE  Dump as ascii printable characters

enum MemoryMedium
 

memory access mediums.

Mediums used when operating with memgrep.

Enumeration values:
MEMORY_MEDIUM_UNKNOWN  An unknown medium
MEMORY_MEDIUM_PID  Access memory via a process id
MEMORY_MEDIUM_CORE  Access memory via a core file


Function Documentation

unsigned long memgrep MEM_CTX   ctx,
unsigned long    cmd,
MEMGREP_RESULT   result,
unsigned long    param,
unsigned long    data
 

The method used to operate memgrep.

Parameters:
ctx  [in] The memgrep context.
cmd  [in] The command to execute. See each command for a description of its parameters.
result  [out] The result of a given action. This can be NULL.
param  [in] An arbitrary parameter for a given command.
data  [in] An arbitrary parameter for a given command.
Returns:
Return values vary from one command to another.
Examples:
simple.c.


Generated on Mon Dec 29 02:04:13 2003 for memgrep by doxygen1.2.15