Skip to content

Commit

Permalink
interceptor: Simplify the x86 enter thunk logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed May 24, 2024
1 parent 97b65df commit 95839d4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gum/backend-x86/guminterceptor-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ gum_emit_enter_thunk (GumX86Writer * cw)
{
const gssize return_address_stack_displacement = 0;
const gchar * prepare_trap_on_leave = "prepare_trap_on_leave";
gpointer epilog;

gum_emit_prolog (cw, return_address_stack_displacement);

Expand All @@ -366,24 +365,25 @@ gum_emit_enter_thunk (GumX86Writer * cw)

if ((cw->cpu_features & GUM_CPU_CET_SS) != 0)
{
gpointer epilog;

gum_x86_writer_put_test_reg_reg (cw, GUM_X86_EAX, GUM_X86_EAX);
gum_x86_writer_put_jcc_short_label (cw, X86_INS_JNE, prepare_trap_on_leave,
GUM_NO_HINT);

epilog = gum_x86_writer_cur (cw);
}

gum_emit_epilog (cw, GUM_POINT_ENTER);
gum_emit_epilog (cw, GUM_POINT_ENTER);

if ((cw->cpu_features & GUM_CPU_CET_SS) != 0)
{
gum_x86_writer_put_label (cw, prepare_trap_on_leave);

gum_x86_writer_put_mov_reg_address (cw, GUM_X86_XAX, GUM_ADDRESS (epilog));
gum_x86_writer_put_jmp_reg_offset_ptr (cw, GUM_X86_XBX,
G_STRUCT_OFFSET (GumFunctionContext, backend_data) +
G_STRUCT_OFFSET (GumX86FunctionContextData, push_to_shadow_stack));
}
else
{
gum_emit_epilog (cw, GUM_POINT_ENTER);
}
}

static void
Expand Down

0 comments on commit 95839d4

Please sign in to comment.