Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed May 10, 2024
1 parent 404cc80 commit 627ad98
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 191 deletions.
13 changes: 5 additions & 8 deletions bindings/gumjs/gumquickstalker.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static const JSCFunctionListEntry gumjs_default_iterator_entries[] =
JS_CFUNC_DEF ("keep", 0, gumjs_default_iterator_keep),
JS_CFUNC_DEF ("putCallout", 0, gumjs_default_iterator_put_callout),
JS_CFUNC_DEF ("putChainingReturn", 0,
gumjs_default_iterator_put_chaining_return),
gumjs_default_iterator_put_chaining_return),
};

static const JSClassDef gumjs_special_iterator_def =
Expand All @@ -220,7 +220,7 @@ static const JSCFunctionListEntry gumjs_special_iterator_entries[] =
JS_CFUNC_DEF ("keep", 0, gumjs_special_iterator_keep),
JS_CFUNC_DEF ("putCallout", 0, gumjs_special_iterator_put_callout),
JS_CFUNC_DEF ("putChainingReturn", 0,
gumjs_special_iterator_put_chaining_return),
gumjs_special_iterator_put_chaining_return),
};

static const JSClassExoticMethods gumjs_probe_args_exotic_methods =
Expand Down Expand Up @@ -1024,8 +1024,7 @@ gum_quick_stalker_iterator_put_callout (GumQuickIterator * self,

static JSValue
gum_quick_stalker_iterator_put_chaining_return (GumQuickIterator * self,
JSContext * ctx,
GumQuickArgs * args)
JSContext * ctx)
{
gum_stalker_iterator_put_chaining_return (self->handle);

Expand Down Expand Up @@ -1158,8 +1157,7 @@ GUMJS_DEFINE_FUNCTION (gumjs_default_iterator_put_chaining_return)
if (!gum_quick_default_iterator_get (ctx, this_val, core, &self))
return JS_EXCEPTION;

return gum_quick_stalker_iterator_put_chaining_return (
&self->iterator, ctx, args);
return gum_quick_stalker_iterator_put_chaining_return (&self->iterator, ctx);
}

static JSValue
Expand Down Expand Up @@ -1288,8 +1286,7 @@ GUMJS_DEFINE_FUNCTION (gumjs_special_iterator_put_chaining_return)
if (!gum_quick_special_iterator_get (ctx, this_val, core, &self))
return JS_EXCEPTION;

return gum_quick_stalker_iterator_put_chaining_return (
&self->iterator, ctx, args);
return gum_quick_stalker_iterator_put_chaining_return (&self->iterator, ctx);
}

static void
Expand Down
5 changes: 2 additions & 3 deletions bindings/gumjs/gumv8stalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@ gum_v8_stalker_iterator_put_callout (GumV8StalkerIterator * self,

static void
gum_v8_stalker_iterator_put_chaining_return (GumV8StalkerIterator * self,
const GumV8Args * args,
Isolate * isolate)
{
if (!gum_v8_stalker_iterator_check_valid (self, isolate))
Expand Down Expand Up @@ -1189,7 +1188,7 @@ GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (
gumjs_stalker_default_iterator_put_chaining_return,
GumV8StalkerDefaultIterator)
{
gum_v8_stalker_iterator_put_chaining_return (&self->iterator, args, isolate);
gum_v8_stalker_iterator_put_chaining_return (&self->iterator, isolate);
}

static GumV8StalkerSpecialIterator *
Expand Down Expand Up @@ -1283,7 +1282,7 @@ GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (
gumjs_stalker_special_iterator_put_chaining_return,
GumV8StalkerSpecialIterator)
{
gum_v8_stalker_iterator_put_chaining_return (&self->iterator, args, isolate);
gum_v8_stalker_iterator_put_chaining_return (&self->iterator, isolate);
}

static void
Expand Down
82 changes: 39 additions & 43 deletions gum/backend-arm/gumstalker-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2511,16 +2511,14 @@ gum_stalker_iterator_arm_next (GumStalkerIterator * self,
gc->continuation_real_address = instruction->end;
return FALSE;
}
else if (!skip_implicitly_requested && gum_arm_relocator_eob (rl))
{

if (!skip_implicitly_requested && gum_arm_relocator_eob (rl))
return FALSE;
}
}

instruction = &self->instruction;

n_read = gum_arm_relocator_read_one (rl, &instruction->ci);

if (n_read == 0)
return FALSE;

Expand Down Expand Up @@ -2572,10 +2570,9 @@ gum_stalker_iterator_thumb_next (GumStalkerIterator * self,
gc->continuation_real_address = instruction->end;
return FALSE;
}
else if (!skip_implicitly_requested && gum_thumb_relocator_eob (rl))
{

if (!skip_implicitly_requested && gum_thumb_relocator_eob (rl))
return FALSE;
}
}

instruction = &self->instruction;
Expand Down Expand Up @@ -2643,30 +2640,6 @@ gum_stalker_iterator_keep (GumStalkerIterator * self)
gum_stalker_iterator_arm_keep (self);
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;
GumBranchTarget target;

target.type = GUM_TARGET_DIRECT_REG_OFFSET;
GumBranchDirectRegOffset * value = &target.value.direct_reg_offset;
value->reg = ARM_REG_LR;
value->offset = 0;
value->mode = GUM_ARM_MODE_CURRENT;

if (gc->is_thumb)
{
gum_exec_block_virtualize_thumb_ret_insn (block, &target, false, 0, gc);
}
else
{
gum_exec_block_virtualize_arm_ret_insn (block, &target, ARM_CC_AL, false,
0, gc);
}
}

GumMemoryAccess
gum_stalker_iterator_get_memory_access (GumStalkerIterator * self)
{
Expand Down Expand Up @@ -3440,6 +3413,31 @@ gum_stalker_invoke_callout (GumCalloutEntry * entry,
ec->pending_calls--;
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;
GumBranchTarget target;
GumBranchDirectRegOffset * value;

target.type = GUM_TARGET_DIRECT_REG_OFFSET;
value = &target.value.direct_reg_offset;
value->reg = ARM_REG_LR;
value->offset = 0;
value->mode = GUM_ARM_MODE_CURRENT;

if (gc->is_thumb)
{
gum_exec_block_virtualize_thumb_ret_insn (block, &target, FALSE, 0, gc);
}
else
{
gum_exec_block_virtualize_arm_ret_insn (block, &target, ARM_CC_AL, FALSE, 0,
gc);
}
}

csh
gum_stalker_iterator_get_capstone (GumStalkerIterator * self)
{
Expand Down Expand Up @@ -4595,11 +4593,11 @@ gum_exec_block_virtualize_thumb_branch_insn (GumExecBlock * block,
gum_exec_block_write_thumb_exec_generated_code (cw, block->ctx);

/*
* We MUST do this last to account for IT blocks. gum_thumb_relocator_skip_one will complete
* the IT branch, so if we do this early (like in arm), then the end branch will be relocated into the
* middle of the relocated branch
*/

* We MUST do this last to account for IT blocks.
* gum_thumb_relocator_skip_one() will complete the IT branch, so if we do
* this early (like on ARM), then the end branch will be relocated into the
* middle of the relocated branch.
*/
gum_thumb_relocator_skip_one (gc->thumb_relocator);
}

Expand Down Expand Up @@ -4660,11 +4658,11 @@ gum_exec_block_virtualize_thumb_call_insn (GumExecBlock * block,
gum_exec_block_write_thumb_exec_generated_code (gc->thumb_writer, block->ctx);

/*
* We MUST do this last to account for IT blocks. gum_thumb_relocator_skip_one will complete
* the IT branch, so if we do this early (like in arm), then the end branch will be relocated into the middle
* of the relocated branch
*/

* We MUST do this last to account for IT blocks.
* gum_thumb_relocator_skip_one() will complete the IT branch, so if we do
* this early (like on ARM), then the end branch will be relocated into the
* middle of the relocated branch.
*/
gum_thumb_relocator_skip_one (gc->thumb_relocator);
}

Expand Down Expand Up @@ -5229,9 +5227,7 @@ gum_exec_block_write_thumb_handle_excluded (GumExecBlock * block,
if (target->type == GUM_TARGET_DIRECT_ADDRESS)
{
if (!check (block->ctx, target->value.direct_address.address))
{
return;
}
}

if (target->type != GUM_TARGET_DIRECT_ADDRESS)
Expand Down
24 changes: 12 additions & 12 deletions gum/backend-arm64/gumstalker-arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -3021,18 +3021,6 @@ gum_stalker_iterator_keep (GumStalkerIterator * self)
self->requirements = requirements;
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;

if ((block->ctx->sink_mask & GUM_RET) != 0)
gum_exec_block_write_ret_event_code (block, gc, GUM_CODE_INTERRUPTIBLE);

gum_exec_block_write_chaining_return_code (block, gc, ARM64_REG_X30);
}

GumMemoryAccess
gum_stalker_iterator_get_memory_access (GumStalkerIterator * self)
{
Expand Down Expand Up @@ -3160,6 +3148,18 @@ gum_stalker_invoke_callout (GumCalloutEntry * entry,
ec->pending_calls--;
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;

if ((block->ctx->sink_mask & GUM_RET) != 0)
gum_exec_block_write_ret_event_code (block, gc, GUM_CODE_INTERRUPTIBLE);

gum_exec_block_write_chaining_return_code (block, gc, ARM64_REG_X30);
}

csh
gum_stalker_iterator_get_capstone (GumStalkerIterator * self)
{
Expand Down
10 changes: 5 additions & 5 deletions gum/backend-mips/gumstalker-mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ gum_stalker_iterator_keep (GumStalkerIterator * self)
{
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
}

GumMemoryAccess
gum_stalker_iterator_get_memory_access (GumStalkerIterator * self)
{
Expand All @@ -225,6 +220,11 @@ gum_stalker_iterator_put_callout (GumStalkerIterator * self,
{
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
}

csh
gum_stalker_iterator_get_capstone (GumStalkerIterator * self)
{
Expand Down
28 changes: 14 additions & 14 deletions gum/backend-x86/gumstalker-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -3245,20 +3245,6 @@ gum_stalker_iterator_keep (GumStalkerIterator * self)
self->requirements = requirements;
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;

if ((block->ctx->sink_mask & GUM_RET) != 0)
gum_exec_block_write_ret_event_code (block, gc, GUM_CODE_INTERRUPTIBLE);

gum_exec_block_write_adjust_depth (block, gc->code_writer, -1);

gum_exec_block_write_chaining_return_code (block, gc, 0);
}

GumMemoryAccess
gum_stalker_iterator_get_memory_access (GumStalkerIterator * self)
{
Expand Down Expand Up @@ -3383,6 +3369,20 @@ gum_stalker_invoke_callout (GumCalloutEntry * entry,
ec->pending_calls--;
}

void
gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;

if ((block->ctx->sink_mask & GUM_RET) != 0)
gum_exec_block_write_ret_event_code (block, gc, GUM_CODE_INTERRUPTIBLE);

gum_exec_block_write_adjust_depth (block, gc->code_writer, -1);

gum_exec_block_write_chaining_return_code (block, gc, 0);
}

csh
gum_stalker_iterator_get_capstone (GumStalkerIterator * self)
{
Expand Down
Loading

0 comments on commit 627ad98

Please sign in to comment.