emu_memory.h File Reference

#include <inttypes.h>
#include <sys/types.h>
Include dependency graph for emu_memory.h:

Go to the source code of this file.

Defines

#define MEM_BYTE_READ(cpu_p, addr, data_p)
#define MEM_BYTE_WRITE(cpu_p, addr, data)
#define MEM_WORD_READ(cpu_p, addr, data_p)
#define MEM_WORD_WRITE(cpu_p, addr, data)
#define MEM_DWORD_READ(cpu_p, addr, data_p)
#define MEM_DWORD_WRITE(cpu_p, addr, data)

Enumerations

enum  emu_segment {
  s_cs = 0, s_ss, s_ds, s_es,
  s_fs, s_gs
}

Functions

struct emu_memoryemu_memory_new (struct emu *e)
void emu_memory_clear (struct emu_memory *em)
void emu_memory_free (struct emu_memory *em)
int32_t emu_memory_read_byte (struct emu_memory *m, uint32_t addr, uint8_t *byte)
int32_t emu_memory_read_word (struct emu_memory *m, uint32_t addr, uint16_t *word)
int32_t emu_memory_read_dword (struct emu_memory *m, uint32_t addr, uint32_t *dword)
int32_t emu_memory_read_block (struct emu_memory *m, uint32_t addr, void *dest, size_t len)
int32_t emu_memory_read_string (struct emu_memory *m, uint32_t addr, struct emu_string *s, uint32_t maxsize)
int32_t emu_memory_write_byte (struct emu_memory *m, uint32_t addr, uint8_t byte)
int32_t emu_memory_write_word (struct emu_memory *m, uint32_t addr, uint16_t word)
int32_t emu_memory_write_dword (struct emu_memory *m, uint32_t addr, uint32_t dword)
int32_t emu_memory_write_block (struct emu_memory *m, uint32_t addr, void *src, size_t len)
void emu_memory_segment_select (struct emu_memory *m, enum emu_segment s)
enum emu_segment emu_memory_segment_get (struct emu_memory *m)
int32_t emu_memory_alloc (struct emu_memory *m, uint32_t *addr, size_t len)
uint32_t emu_memory_get_usage (struct emu_memory *m)
void emu_memory_mode_ro (struct emu_memory *m)
void emu_memory_mode_rw (struct emu_memory *m)

Define Documentation

#define MEM_BYTE_READ ( cpu_p,
addr,
data_p   ) 
#define MEM_BYTE_WRITE ( cpu_p,
addr,
data   ) 
#define MEM_DWORD_READ ( cpu_p,
addr,
data_p   ) 
Value:
{ int32_t ret = emu_memory_read_dword((cpu_p)->mem, addr, data_p); \
 if( ret != 0 ) \
  return ret; }

Referenced by env_w32_hook_fclose(), env_w32_hook_fopen(), env_w32_hook_fwrite(), instr_adc_11(), instr_adc_13(), instr_add_01(), instr_add_03(), instr_and_21(), instr_and_23(), instr_cmp_39(), instr_cmp_3b(), instr_cmps_a7(), instr_group_1_81_adc(), instr_group_1_81_add(), instr_group_1_81_and(), instr_group_1_81_cmp(), instr_group_1_81_or(), instr_group_1_81_sbb(), instr_group_1_81_sub(), instr_group_1_81_xor(), instr_group_1_83_adc(), instr_group_1_83_add(), instr_group_1_83_and(), instr_group_1_83_cmp(), instr_group_1_83_or(), instr_group_1_83_sbb(), instr_group_1_83_sub(), instr_group_1_83_xor(), instr_group_2_c1_rcl(), instr_group_2_c1_rcr(), instr_group_2_c1_rol(), instr_group_2_c1_ror(), instr_group_2_c1_sal(), instr_group_2_c1_sar(), instr_group_2_c1_shr(), instr_group_2_d1_rcl(), instr_group_2_d1_rcr(), instr_group_2_d1_rol(), instr_group_2_d1_ror(), instr_group_2_d1_sal(), instr_group_2_d1_sar(), instr_group_2_d1_shr(), instr_group_2_d3_rcl(), instr_group_2_d3_rcr(), instr_group_2_d3_rol(), instr_group_2_d3_ror(), instr_group_2_d3_sal(), instr_group_2_d3_sar(), instr_group_2_d3_shr(), instr_group_3_f7_div(), instr_group_3_f7_idiv(), instr_group_3_f7_imul(), instr_group_3_f7_mul(), instr_group_3_f7_neg(), instr_group_3_f7_not(), instr_group_3_f7_test(), instr_group_5_ff_call(), instr_group_5_ff_dec(), instr_group_5_ff_inc(), instr_group_5_ff_jmp(), instr_group_5_ff_push(), instr_imul_0f_af(), instr_imul_69(), instr_imul_6b(), instr_lods_ad(), instr_mov_8b(), instr_mov_a1(), instr_or_09(), instr_or_0b(), instr_sbb_19(), instr_sbb_1b(), instr_scas_af(), instr_sub_29(), instr_sub_2b(), instr_test_85(), instr_xchg_87(), instr_xor_31(), and instr_xor_33().

#define MEM_DWORD_WRITE ( cpu_p,
addr,
data   ) 
#define MEM_WORD_READ ( cpu_p,
addr,
data_p   ) 
Value:
{ int32_t ret = emu_memory_read_word((cpu_p)->mem, addr, data_p); \
 if( ret != 0 ) \
  return ret; }

Referenced by instr_adc_11(), instr_adc_13(), instr_add_01(), instr_add_03(), instr_and_21(), instr_and_23(), instr_cmp_39(), instr_cmp_3b(), instr_cmps_a7(), instr_group_1_81_adc(), instr_group_1_81_add(), instr_group_1_81_and(), instr_group_1_81_cmp(), instr_group_1_81_or(), instr_group_1_81_sbb(), instr_group_1_81_sub(), instr_group_1_81_xor(), instr_group_1_83_adc(), instr_group_1_83_add(), instr_group_1_83_and(), instr_group_1_83_cmp(), instr_group_1_83_or(), instr_group_1_83_sbb(), instr_group_1_83_sub(), instr_group_1_83_xor(), instr_group_2_c1_rcl(), instr_group_2_c1_rcr(), instr_group_2_c1_rol(), instr_group_2_c1_ror(), instr_group_2_c1_sal(), instr_group_2_c1_sar(), instr_group_2_c1_shr(), instr_group_2_d1_rcl(), instr_group_2_d1_rcr(), instr_group_2_d1_rol(), instr_group_2_d1_ror(), instr_group_2_d1_sal(), instr_group_2_d1_sar(), instr_group_2_d1_shr(), instr_group_2_d3_rcl(), instr_group_2_d3_rcr(), instr_group_2_d3_rol(), instr_group_2_d3_ror(), instr_group_2_d3_sal(), instr_group_2_d3_sar(), instr_group_2_d3_shr(), instr_group_3_f7_div(), instr_group_3_f7_idiv(), instr_group_3_f7_imul(), instr_group_3_f7_mul(), instr_group_3_f7_neg(), instr_group_3_f7_not(), instr_group_3_f7_test(), instr_group_5_ff_call(), instr_group_5_ff_dec(), instr_group_5_ff_inc(), instr_group_5_ff_jmp(), instr_group_5_ff_push(), instr_imul_0f_af(), instr_imul_69(), instr_imul_6b(), instr_lods_ad(), instr_mov_8b(), instr_mov_a1(), instr_movsx_0fbf(), instr_movzx_0fb7(), instr_or_09(), instr_or_0b(), instr_sbb_19(), instr_sbb_1b(), instr_scas_af(), instr_sub_29(), instr_sub_2b(), instr_test_85(), instr_xchg_87(), instr_xor_31(), and instr_xor_33().

#define MEM_WORD_WRITE ( cpu_p,
addr,
data   ) 

Enumeration Type Documentation

Enumerator:
s_cs 
s_ss 
s_ds 
s_es 
s_fs 
s_gs 

Function Documentation

int32_t emu_memory_alloc ( struct emu_memory m,
uint32_t *  addr,
size_t  len 
)

References page_alloc(), page_is_alloc(), and PAGE_SIZE.

Referenced by env_w32_hook_malloc().

Here is the call graph for this function:

void emu_memory_clear ( struct emu_memory em  ) 
void emu_memory_free ( struct emu_memory em  ) 
uint32_t emu_memory_get_usage ( struct emu_memory m  ) 
void emu_memory_mode_ro ( struct emu_memory m  ) 
void emu_memory_mode_rw ( struct emu_memory m  ) 
struct emu_memory* emu_memory_new ( struct emu e  )  [read]
int32_t emu_memory_read_block ( struct emu_memory m,
uint32_t  addr,
void *  dest,
size_t  len 
)
int32_t emu_memory_read_byte ( struct emu_memory m,
uint32_t  addr,
uint8_t *  byte 
)

References emu_memory::emu, emu_errno_set(), emu_strerror_set(), emu_memory::segment_offset, and translate_addr().

Referenced by emu_cpu_parse().

Here is the call graph for this function:

int32_t emu_memory_read_dword ( struct emu_memory m,
uint32_t  addr,
uint32_t *  dword 
)
int32_t emu_memory_read_string ( struct emu_memory m,
uint32_t  addr,
struct emu_string s,
uint32_t  maxsize 
)
int32_t emu_memory_read_word ( struct emu_memory m,
uint32_t  addr,
uint16_t *  word 
)

References emu_memory_read_block().

Referenced by emu_cpu_parse().

Here is the call graph for this function:

enum emu_segment emu_memory_segment_get ( struct emu_memory m  ) 
void emu_memory_segment_select ( struct emu_memory m,
enum emu_segment  s 
)
int32_t emu_memory_write_block ( struct emu_memory m,
uint32_t  addr,
void *  src,
size_t  len 
)
int32_t emu_memory_write_byte ( struct emu_memory m,
uint32_t  addr,
uint8_t  byte 
)

References page_alloc(), emu_memory::read_only_access, emu_memory::segment_offset, and translate_addr().

Here is the call graph for this function:

int32_t emu_memory_write_dword ( struct emu_memory m,
uint32_t  addr,
uint32_t  dword 
)

References emu_memory_write_block(), and emu_memory::read_only_access.

Referenced by emu_env_w32_new(), env_w32_hook_CreateProcessA(), and env_w32_hook_WriteFile().

Here is the call graph for this function:

int32_t emu_memory_write_word ( struct emu_memory m,
uint32_t  addr,
uint16_t  word 
)

References emu_memory_write_block(), and emu_memory::read_only_access.

Here is the call graph for this function:


Generated on Sun Jan 9 16:48:16 2011 for libemu by  doxygen 1.6.1