Skip to content

Commit

Permalink
find_*_instruction_with_mem_operand
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Apr 4, 2024
1 parent 32d0e9d commit 5283800
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
50 changes: 50 additions & 0 deletions xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,56 @@ extern BOOL find_call_instruction(u8 *code_start, u8 *code_end, u8 *call_target,
*/
extern BOOL find_lea_instruction(u8 *code_start, u8 *code_end, u64 displacement);

/**
* @brief finds a LEA or MOV instruction with an immediate memory operand
*
* @param code_start address to start searching from
* @param code_end address to stop searching at
* @param dctx disassembler context to hold the state
* @param mem_address the expected address of the memory access
* @return BOOL TRUE if found, FALSE otherwise
*/
extern BOOL find_instruction_with_mem_operand(
u8 *code_start,
u8 *code_end,
dasm_ctx_t *dctx,
u8 *mem_address
);

/**
* @brief finds a LEA instruction with an immediate memory operand
*
* @param code_start address to start searching from
* @param code_end address to stop searching at
* @param dctx disassembler context to hold the state
* @param mem_address the expected address of the memory access
* @return BOOL TRUE if found, FALSE otherwise
*/
extern BOOL find_lea_instruction_with_mem_operand(
u8 *code_start,
u8 *code_end,
dasm_ctx_t *dctx,
u8 *mem_address
);

/**
* @brief finds an instruction with an immediate memory operand
*
* @param code_start address to start searching from
* @param code_end address to stop searching at
* @param dctx disassembler context to hold the state
* @param opcode opcode to look for, in encoded form (+0x80)
* @param mem_address the expected address of the memory access
* @return BOOL TRUE if found, FALSE otherwise
*/
extern BOOL find_instruction_with_mem_operand_ex(
u8 *code_start,
u8 *code_end,
dasm_ctx_t *dctx,
int opcode,
u8 *mem_address
);

/**
* @brief finds a reg2reg instruction
*
Expand Down
9 changes: 9 additions & 0 deletions xzre.lds
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ SECTIONS {
"find_lea_instruction" = ".";
*(.text.lzma_raw_encodea);

"find_instruction_with_mem_operand" = ".";
*(.text.stream_encoder_mt_inia);

"find_lea_instruction_with_mem_operand" = ".";
*(.text.lzma_mt_block_siza);

"find_instruction_with_mem_operand_ex" = ".";
*(.text.lzma_properties_siza);

"find_function_prologue" = ".";
*(.text.lzma_raw_coder_memusaga);

Expand Down

0 comments on commit 5283800

Please sign in to comment.