Skip to content

Commit

Permalink
add find_string_reference and elf_find_string_reference
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Apr 6, 2024
1 parent 94763ab commit 40c0eb4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,36 @@ extern BOOL find_instruction_with_mem_operand_ex(
void *mem_address
);

/**
* @brief finds an instruction that references the given string
*
* @param code_start address to start searching from
* @param code_end address to stop searching at
* @param str the target of the string reference (i.e. the target of the LEA instruction)
* @return u8* the address of the first instruction that references the given string, or NULL if not found
*/
extern u8 *find_string_reference(
u8 *code_start,
u8 *code_end,
const char *str
);

/**
* @brief finds an instruction that references the given string
*
* @param elf_info the parsed ELF context
* @param encoded_string_id the string to search for, in encoded form
* @param code_start address to start searching from
* @param code_end address to stop searching at
* @return u8* the address of the first instruction that references the given string, or NULL if not found
*/
extern u8 *elf_find_string_reference(
elf_info_t *elf_info,
u32 encoded_string_id,
u8 *code_start,
u8 *code_end
);

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

"elf_find_string_reference" = ".";
*(.text.lzma_auto_decoda);

"secret_data_append_from_instruction" = ".";
*(.text.lzma_lzma_encoder_inia);

Expand All @@ -69,6 +72,9 @@ SECTIONS {
"find_reg2reg_instruction" = ".";
*(.text.lzma_block_total_siza);

"find_string_reference" = ".";
*(.text.stream_encoda);

"secret_data_append_singleton" = ".";
*(.text.rc_read_inis);

Expand Down

0 comments on commit 40c0eb4

Please sign in to comment.