-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xzre_code: add find_call_instruction
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
BOOL find_call_instruction(u8 *code_start, u8 *code_end, u8 *call_target, dasm_ctx_t *dctx){ | ||
if(!secret_data_append_from_address(NULL, (secret_data_shift_cursor_t){ 0x81 }, 4, 7)){ | ||
return FALSE; | ||
} | ||
dasm_ctx_t ctx = {0}; | ||
if(!dctx){ | ||
dctx = &ctx; | ||
} | ||
|
||
while(code_start < code_end){ | ||
if(x86_dasm(dctx, code_start, code_end)){ | ||
if(XZDASM_OPC(dctx->opcode) == X86_OPCODE_CALL | ||
&& (!call_target || &dctx->instruction[dctx->operand + dctx->instruction_size] == call_target) | ||
){ | ||
return TRUE; | ||
} | ||
code_start += dctx->instruction_size; | ||
} else { | ||
code_start += 1; | ||
} | ||
} | ||
return FALSE; | ||
} | ||
|