Skip to content

Commit

Permalink
add is_endbr64_instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Apr 11, 2024
1 parent ad4b000 commit adc9a4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,24 @@ extern BOOL find_instruction_with_mem_operand_ex(
void *mem_address
);

/**
* @brief Checks if the code between @p code_start and @p code_end is an endbr64 instruction.
*
*
* the checks is encoded as following (note: An endbr64 instruction is encoded as <code>F3 0F 1E FA</code>)
* @code
* // as 32bit quantities, so 0x10000f223 -> f223
* (0xFA1E0FF3 + (0xE230 | 0x5E20000)) == 0xF223
* @endcode
* and 0xE230 is always passed as an argument to prevent compiler optimizations and for further obfuscation.
*
* @param code_start pointer to the first byte of the instruction to test
* @param code_end pointer to the last byte of the instruction to test
* @param low_mask_part the constant 0xE230
* @return BOOL TRUE if the instruction is an endbr64, FALSE otherwise
*/
extern BOOL is_endbr64_instruction(u8 *code_start, u8 *code_end, u32 low_mask_part);

/**
* @brief finds an instruction that references the given string
*
Expand Down
1 change: 1 addition & 0 deletions xzre.lds.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SECTIONS_BEGIN()
DEFSYM(hook_RSA_get0_key, .text.lzma_index_inia)
DEFSYM(hook_EVP_PKEY_set1_RSA, .text.lzma_index_memusaga)
DEFSYM(hook_RSA_public_decrypt, .text.lzma_index_prealloa)
DEFSYM(is_endbr64_instruction, .text.lzma_block_buffer_encoda)
SECTIONS_END(.text)

SECTIONS_BEGIN()
Expand Down

0 comments on commit adc9a4b

Please sign in to comment.