Skip to content

Commit

Permalink
thcrap: add cave_exec evaluation function that allows expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
32th-System committed Aug 15, 2022
1 parent cfa4204 commit 509610e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions thcrap/src/breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ int breakpoint_cave_exec_flag(json_t *bp_info)
return json_eval_int_default(json_object_get(bp_info, "cave_exec"), 1, JEVAL_DEFAULT);
}

int breakpoint_cave_exec_flag_eval(x86_reg_t* regs, json_t* bp_info) {
json_t* cave_exec = json_object_get(bp_info, "cave_exec");
if (cave_exec) {
return json_immediate_value(cave_exec, regs);
}
return 1;
}

size_t TH_CDECL breakpoint_process(breakpoint_t *bp, size_t addr_index, x86_reg_t regs)
{
// POPAD ignores the ESP register, so we have to implement our own mechanism
Expand Down
3 changes: 3 additions & 0 deletions thcrap/src/breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ bool breakpoint_from_json(const char *name, json_t *in, breakpoint_t *out);
// (since that code might overwrite the modified data otherwise).
int breakpoint_cave_exec_flag(json_t *bp_info);

// Same as above but will evaluate expressions
int breakpoint_cave_exec_flag_eval(x86_reg_t* regs, json_t* bp_info);

// Sets up all breakpoints in [breakpoints], and returns the number of
// breakpoints that could not be applied. [hMod] is used as the base
// for relative addresses.
Expand Down
1 change: 1 addition & 0 deletions thcrap/thcrap.def
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ EXPORTS
json_object_get_pointer
json_object_get_immediate
breakpoint_cave_exec_flag
breakpoint_cave_exec_flag_eval
breakpoint_process
breakpoints_apply

Expand Down

0 comments on commit 509610e

Please # to comment.