Skip to content

Commit

Permalink
Additional formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mineo333 committed Feb 25, 2024
1 parent 60c58a2 commit dc798d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
37 changes: 20 additions & 17 deletions gum/backend-arm/gumstalker-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,9 @@ 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)){
}
else if (!skip_implicitly_requested && gum_arm_relocator_eob (rl))
{
return FALSE;
}
}
Expand Down Expand Up @@ -2510,7 +2512,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)){
}
else if (!skip_implicitly_requested && gum_thumb_relocator_eob (rl))
{
return FALSE;
}
}
Expand Down Expand Up @@ -2585,20 +2589,22 @@ gum_stalker_iterator_put_chaining_return (GumStalkerIterator * self)
{
GumExecBlock * block = self->exec_block;
GumGeneratorContext * gc = self->generator_context;
GumBranchTarget target = {0};
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);
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
Expand Down Expand Up @@ -2730,13 +2736,13 @@ gum_stalker_iterator_handle_thumb_branch_insn (GumStalkerIterator * self,
case ARM_INS_MOV:
gum_stalker_get_target_address (insn, TRUE, &target, &mask);
gum_exec_block_virtualize_thumb_ret_insn (block, &target, FALSE, 0, gc);
gum_thumb_relocator_skip_one(gc->thumb_relocator);
gum_thumb_relocator_skip_one (gc->thumb_relocator);
break;
case ARM_INS_POP:
case ARM_INS_LDM:
gum_stalker_get_target_address (insn, TRUE, &target, &mask);
gum_exec_block_virtualize_thumb_ret_insn (block, &target, TRUE, mask, gc);
gum_thumb_relocator_skip_one(gc->thumb_relocator);
gum_thumb_relocator_skip_one (gc->thumb_relocator);
break;
case ARM_INS_SMC:
case ARM_INS_HVC:
Expand Down Expand Up @@ -4534,8 +4540,7 @@ gum_exec_block_virtualize_thumb_branch_insn (GumExecBlock * block,
* middle of the relocated branch
*/

gum_thumb_relocator_skip_one(gc->thumb_relocator);

gum_thumb_relocator_skip_one (gc->thumb_relocator);
}

static void
Expand Down Expand Up @@ -4566,7 +4571,6 @@ gum_exec_block_virtualize_arm_call_insn (GumExecBlock * block,
gum_arm_writer_put_ldr_reg_address (gc->arm_writer, ARM_REG_LR,
GUM_ADDRESS (ret_real_address));
gum_exec_block_write_arm_exec_generated_code (gc->arm_writer, block->ctx);

}

static void
Expand Down Expand Up @@ -4601,8 +4605,7 @@ gum_exec_block_virtualize_thumb_call_insn (GumExecBlock * block,
* of the relocated branch
*/

gum_thumb_relocator_skip_one(gc->thumb_relocator);

gum_thumb_relocator_skip_one (gc->thumb_relocator);
}

static void
Expand Down Expand Up @@ -5099,7 +5102,8 @@ gum_exec_block_write_arm_handle_excluded (GumExecBlock * block,
*/
if (target->type == GUM_TARGET_DIRECT_ADDRESS)
{
if (!check (block->ctx, target->value.direct_address.address)){
if (!check (block->ctx, target->value.direct_address.address))
{
gum_arm_relocator_skip_one (gc->arm_relocator);
return;
}
Expand Down Expand Up @@ -5167,7 +5171,6 @@ gum_exec_block_write_thumb_handle_excluded (GumExecBlock * block,
if (!check (block->ctx, target->value.direct_address.address)){
return;
}

}

if (target->type != GUM_TARGET_DIRECT_ADDRESS)
Expand Down
14 changes: 4 additions & 10 deletions tests/core/arch-arm/stalker-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3237,10 +3237,6 @@ TESTCODE (arm_simple_call,

TESTCASE (arm_transformer_should_be_able_to_replace_call_with_callout)
{
guint32 code[CODE_SIZE (arm_simple_call) / sizeof (guint32)];

memcpy (code, arm_simple_call, CODE_SIZE (arm_simple_call));

fixture->transformer = gum_stalker_transformer_make_from_callback (
replace_call_with_callout, NULL, NULL);

Expand All @@ -3260,7 +3256,9 @@ replace_call_with_callout (GumStalkerIterator * iterator,
{
gum_stalker_iterator_put_callout (iterator, callout_set_cool,
NULL, NULL);
} else {
}
else
{
gum_stalker_iterator_keep (iterator);
}
insn_num++;
Expand All @@ -3277,14 +3275,10 @@ TESTCODE (arm_simple_jumpout,

TESTCASE (arm_transformer_should_be_able_to_replace_jumpout_with_callout)
{
guint32 code[CODE_SIZE (arm_simple_jumpout) / sizeof (guint32)];

memcpy (code, arm_simple_jumpout, CODE_SIZE (arm_simple_jumpout));

fixture->transformer = gum_stalker_transformer_make_from_callback (
replace_jumpout_with_callout, NULL, NULL);

INVOKE_ARM_EXPECTING (GUM_EXEC, code, 0xc001);
INVOKE_ARM_EXPECTING (GUM_EXEC, arm_simple_jumpout, 0xc001);
}

static void
Expand Down

0 comments on commit dc798d1

Please sign in to comment.