diff --git a/gum-32.vcxproj.filters b/gum-32.vcxproj.filters index 8b3532ff9..a0c7b170b 100644 --- a/gum-32.vcxproj.filters +++ b/gum-32.vcxproj.filters @@ -31,6 +31,12 @@ {c9fdd7fd-d1cb-41ce-a511-b326acab51f1} + + {3de8e70e-7e64-469c-bca3-90eb555c03c3} + + + {12159555-5953-43fc-873d-2754adb9b815} + @@ -186,9 +192,6 @@ libs\heap - - core\backend-x86 - core @@ -225,6 +228,24 @@ core\backend-windows + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + @@ -413,9 +434,6 @@ libs\heap - - core - core @@ -458,6 +476,30 @@ udis86 + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + @@ -469,4 +511,4 @@ udis86 - + \ No newline at end of file diff --git a/gum-64.vcxproj.filters b/gum-64.vcxproj.filters index fa8a23cd5..7830ff576 100644 --- a/gum-64.vcxproj.filters +++ b/gum-64.vcxproj.filters @@ -7,9 +7,6 @@ {37ab3c51-1983-4479-91c9-010eb64aae2f} - - {41ad8d23-ee83-4901-a2ac-26b1e995b0b3} - {344c8464-6e81-4ed7-b64f-62e262bf6134} @@ -31,6 +28,15 @@ {4f6067a4-9b67-4259-a2b6-8c902581f2c6} + + {422492e7-f2de-49a2-923f-f70237e2f44c} + + + {8e89e69d-014f-4730-8e4b-ed9caa938949} + + + {41ad8d23-ee83-4901-a2ac-26b1e995b0b3} + @@ -186,9 +192,6 @@ libs\heap - - core\backend-x86 - core @@ -225,6 +228,24 @@ core\backend-windows + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + @@ -413,9 +434,6 @@ libs\heap - - core - core @@ -458,6 +476,30 @@ udis86 + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm64 + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + + + core\arch-arm + @@ -469,4 +511,4 @@ udis86 - + \ No newline at end of file diff --git a/gum-common.props b/gum-common.props index 0d9920bcd..937f4a8fb 100644 --- a/gum-common.props +++ b/gum-common.props @@ -12,7 +12,6 @@ - @@ -94,7 +93,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gum/arch-arm/gumarmrelocator.c b/gum/arch-arm/gumarmrelocator.c index 4cf9bd9d1..5b3ac6547 100644 --- a/gum/arch-arm/gumarmrelocator.c +++ b/gum/arch-arm/gumarmrelocator.c @@ -110,7 +110,7 @@ gum_arm_relocator_read_one (GumArmRelocator * self, raw_insn = GUINT32_FROM_LE (*((guint32 *) self->input_cur)); insn = &self->input_insns[gum_arm_relocator_inpos (self)]; - category = (raw_insn >> 25) & 0b111; + category = (raw_insn >> 25) & 7; insn->mnemonic = GUM_ARM_UNKNOWN; insn->address = self->input_cur; @@ -119,33 +119,33 @@ gum_arm_relocator_read_one (GumArmRelocator * self, switch (category) { - case 0b000: /* data processing */ - case 0b001: + case 0: /* data processing */ + case 1: { - guint opcode = (raw_insn >> 21) & 0b1111; + guint opcode = (raw_insn >> 21) & 0xf; switch (opcode) { - case 0b1101: + case 0xd: insn->mnemonic = GUM_ARM_MOV; break; } break; } - case 0b010: /* load/store */ + case 2: /* load/store */ break; - case 0b100: /* load/store multiple */ + case 4: /* load/store multiple */ { - guint base_register = (raw_insn >> 16) & 0b1111; + guint base_register = (raw_insn >> 16) & 0xf; guint is_load = (raw_insn >> 20) & 1; if (base_register == GUM_AREG_SP) insn->mnemonic = is_load ? GUM_ARM_POP : GUM_ARM_PUSH; break; } - case 0b101: /* control */ - if (((raw_insn >> 28) & 0b1111) == 0b1111) + case 5: /* control */ + if (((raw_insn >> 28) & 0xf) == 0xf) { insn->mnemonic = GUM_ARM_BLX_IMM_A2; } @@ -324,6 +324,8 @@ gum_arm_relocator_rewrite_branch_imm (GumArmRelocator * self, } distance; GumAddress absolute_target; + (void) self; + raw_insn = *ctx->raw_insn; if ((raw_insn & 0x00800000) != 0) distance.u = 0xfc000000 | ((raw_insn & 0x00ffffff) << 2); diff --git a/gum/arch-arm/gumarmwriter.c b/gum/arch-arm/gumarmwriter.c index fafccb9f2..e67328052 100644 --- a/gum/arch-arm/gumarmwriter.c +++ b/gum/arch-arm/gumarmwriter.c @@ -72,7 +72,7 @@ gum_arm_writer_cur (GumArmWriter * self) guint gum_arm_writer_offset (GumArmWriter * self) { - return (self->code - self->base) * sizeof (guint32); + return (guint) (self->code - self->base) * sizeof (guint32); } void diff --git a/gum/arch-arm/gumthumbrelocator.c b/gum/arch-arm/gumthumbrelocator.c index 3a83c3830..2c7590097 100644 --- a/gum/arch-arm/gumthumbrelocator.c +++ b/gum/arch-arm/gumthumbrelocator.c @@ -118,8 +118,8 @@ gum_thumb_relocator_read_one (GumThumbRelocator * self, raw_insn = GUINT16_FROM_LE (*((guint16 *) self->input_cur)); insn = &self->input_insns[gum_thumb_relocator_inpos (self)]; - group = (raw_insn >> 12) & 0b1111; - operation = (raw_insn >> 8) & 0b1111; + group = (raw_insn >> 12) & 0xf; + operation = (raw_insn >> 8) & 0xf; insn->mnemonic = GUM_ARM_UNKNOWN; insn->address = self->input_cur; @@ -128,31 +128,31 @@ gum_thumb_relocator_read_one (GumThumbRelocator * self, switch (group) { - case 0b0100: + case 0x4: if (operation == 4) insn->mnemonic = GUM_ARM_ADDH; else if (operation >= 8) insn->mnemonic = GUM_ARM_LDRPC; break; - case 0b1010: + case 0xa: if (operation < 8) insn->mnemonic = GUM_ARM_ADDPC; else insn->mnemonic = GUM_ARM_ADDSP; break; - case 0b1011: + case 0xb: if (operation == 4 || operation == 5) insn->mnemonic = GUM_ARM_PUSH; break; - case 0b1110: + case 0xe: if (((raw_insn >> 11) & 1) == 0) insn->mnemonic = GUM_ARM_B_IMM_T2; break; - case 0b1111: + case 0xf: { guint32 wide_insn; @@ -363,6 +363,8 @@ gum_thumb_relocator_rewrite_addh_if_pc_relative (GumThumbRelocator * self, GumArmReg src_reg, dst_reg, temp_reg; gboolean dst_reg_is_upper; + (void) self; + src_reg = (insn & 0x78) >> 3; if (src_reg != GUM_AREG_PC) return FALSE; @@ -393,6 +395,8 @@ gum_thumb_relocator_rewrite_ldr_pc (GumThumbRelocator * self, GumArmReg reg; GumAddress absolute_pc; + (void) self; + reg = (insn & 0x0700) >> 8; absolute_pc = ctx->insn->pc & ~(4 - 1); @@ -415,6 +419,10 @@ gum_thumb_relocator_rewrite_b_imm (GumThumbRelocator * self, } distance; GumAddress absolute_target; + (void) self; + + distance.u = 0; + switch (ctx->insn->mnemonic) { case GUM_ARM_B_IMM_T2: @@ -422,10 +430,9 @@ gum_thumb_relocator_rewrite_b_imm (GumThumbRelocator * self, guint16 insn = GUINT16_FROM_LE (*ctx->raw_insn); guint32 imm11; - imm11 = insn & 0b11111111111; + imm11 = insn & 0x7ff; - distance.u = ((imm11 & 0b10000000000) ? 0xfffff000 : 0x00000000) | - (imm11 << 1); + distance.u = ((imm11 & 0x400) ? 0xfffff000 : 0x00000000) | (imm11 << 1); break; } @@ -443,8 +450,8 @@ gum_thumb_relocator_rewrite_b_imm (GumThumbRelocator * self, j2 = (insn >> 11) & 1; i1 = ~(j1 ^ s) & 1; i2 = ~(j2 ^ s) & 1; - imm10_h = (insn >> 16) & 0b1111111111; - imm11_l = insn & 0b11111111111; + imm10_h = (insn >> 16) & 0x3ff; + imm11_l = insn & 0x7ff; distance.u = (s ? 0xff000000 : 0x00000000) | (i1 << 23) | (i2 << 22) | (imm10_h << 12) | (imm11_l << 1); @@ -482,6 +489,8 @@ gum_thumb_relocator_rewrite_bl_imm (GumThumbRelocator * self, } distance; GumAddress absolute_target; + (void) self; + insn = ((guint32) GUINT16_FROM_LE (*(ctx->raw_insn))) << 16 | (guint32) GUINT16_FROM_LE (*(ctx->raw_insn + 1)); @@ -491,8 +500,8 @@ gum_thumb_relocator_rewrite_bl_imm (GumThumbRelocator * self, j2 = (insn >> 11) & 1; i1 = ~(j1 ^ s) & 1; i2 = ~(j2 ^ s) & 1; - imm10_h = (insn >> 16) & 0b1111111111; - imm11_l = insn & 0b11111111111; + imm10_h = (insn >> 16) & 0x3ff; + imm11_l = insn & 0x7ff; distance.u = (s ? 0xff000000 : 0x00000000) | (i1 << 23) | (i2 << 22) | (imm10_h << 12) | (imm11_l << 1); diff --git a/gum/arch-arm/gumthumbwriter.c b/gum/arch-arm/gumthumbwriter.c index 4d859258f..129701d39 100644 --- a/gum/arch-arm/gumthumbwriter.c +++ b/gum/arch-arm/gumthumbwriter.c @@ -95,7 +95,7 @@ gum_thumb_writer_cur (GumThumbWriter * self) guint gum_thumb_writer_offset (GumThumbWriter * self) { - return (self->code - self->base) * sizeof (guint16); + return (guint) (self->code - self->base) * sizeof (guint16); } void diff --git a/gum/arch-arm64/gumarm64writer.c b/gum/arch-arm64/gumarm64writer.c index d23edab78..a8e90b8bf 100644 --- a/gum/arch-arm64/gumarm64writer.c +++ b/gum/arch-arm64/gumarm64writer.c @@ -192,7 +192,7 @@ gum_arm64_writer_cur (GumArm64Writer * self) guint gum_arm64_writer_offset (GumArm64Writer * self) { - return (self->code - self->base) * sizeof (guint32); + return (guint) (self->code - self->base) * sizeof (guint32); } void @@ -231,17 +231,16 @@ gum_arm64_writer_flush (GumArm64Writer * self) if (self->literal_refs_len > 0) { - guint64 * first_slot, * last_slot; + gint64 * first_slot, * last_slot; guint ref_idx; - first_slot = (guint64 *) self->code; + first_slot = (gint64 *) self->code; last_slot = first_slot; for (ref_idx = 0; ref_idx != self->literal_refs_len; ref_idx++) { GumArm64LiteralRef * r; - guint64 * cur_slot; - gint64 distance; + gint64 * cur_slot, distance; guint32 insn; r = &self->literal_refs[ref_idx]; @@ -402,6 +401,8 @@ static void gum_arm64_writer_put_argument_list_teardown (GumArm64Writer * self, guint n_args) { + (void) self; + (void) n_args; } gboolean @@ -571,12 +572,12 @@ gum_arm64_writer_put_push_reg_reg (GumArm64Writer * self, if (ra.width == 64) { gum_arm64_writer_put_load_store_pair_pre (self, GUM_MEM_PAIR_OPERAND_64, - 0b10, FALSE, FALSE, ra.index, rb.index, GUM_A64REG_SP, -16); + 2, FALSE, FALSE, ra.index, rb.index, GUM_A64REG_SP, -16); } else { gum_arm64_writer_put_load_store_pair_pre (self, GUM_MEM_PAIR_OPERAND_32, - 0b00, FALSE, FALSE, ra.index, rb.index, GUM_A64REG_SP, -8); + 0, FALSE, FALSE, ra.index, rb.index, GUM_A64REG_SP, -8); } } @@ -595,12 +596,12 @@ gum_arm64_writer_put_pop_reg_reg (GumArm64Writer * self, if (ra.width == 64) { gum_arm64_writer_put_load_store_pair_post (self, GUM_MEM_PAIR_OPERAND_64, - 0b10, FALSE, TRUE, ra.index, rb.index, GUM_A64REG_SP, 16); + 2, FALSE, TRUE, ra.index, rb.index, GUM_A64REG_SP, 16); } else { gum_arm64_writer_put_load_store_pair_post (self, GUM_MEM_PAIR_OPERAND_32, - 0b00, FALSE, TRUE, ra.index, rb.index, GUM_A64REG_SP, 8); + 0, FALSE, TRUE, ra.index, rb.index, GUM_A64REG_SP, 8); } } @@ -760,8 +761,8 @@ gum_arm64_writer_put_load_store_pair_pre (GumArm64Writer * self, gssize pre_increment) { gsize shift = gum_mem_pair_offset_shift (op_size, v); - gum_arm64_writer_put_instruction (self, (opc << 30) | (0b101 << 27) | - (v << 26) | (0b011 << 23) | (l << 22) | + gum_arm64_writer_put_instruction (self, (opc << 30) | (5 << 27) | + (v << 26) | (3 << 23) | (l << 22) | (((pre_increment >> shift) & 0x7f) << 15) | (rt2 << 10) | (rn << 5) | rt); } @@ -778,8 +779,8 @@ gum_arm64_writer_put_load_store_pair_post (GumArm64Writer * self, gssize post_increment) { gsize shift = gum_mem_pair_offset_shift (op_size, v); - gum_arm64_writer_put_instruction (self, (opc << 30) | (0b101 << 27) | - (v << 26) | (0b001 << 23) | (l << 22) | + gum_arm64_writer_put_instruction (self, (opc << 30) | (5 << 27) | + (v << 26) | (1 << 23) | (l << 22) | (((post_increment >> shift) & 0x7f) << 15) | (rt2 << 10) | (rn << 5) | rt); } @@ -816,6 +817,8 @@ gum_arm64_writer_describe_reg (GumArm64Writer * self, GumArm64Reg reg, GumArm64RegInfo * ri) { + (void) self; + if ((reg >= GUM_A64REG_X0 && reg <= GUM_A64REG_X30) || reg == 31 || (reg >= GUM_A64REG_PC && reg <= GUM_A64REG_NONE)) diff --git a/tests/core/arch-arm/armrelocator.c b/tests/core/arch-arm/armrelocator.c index c74d2d7dd..f7a8e8be7 100644 --- a/tests/core/arch-arm/armrelocator.c +++ b/tests/core/arch-arm/armrelocator.c @@ -214,8 +214,8 @@ branch_scenario_execute (BranchScenario * bs, { guint32 calculated_lr; - calculated_lr = fixture->aw.pc + - (bs->expected_lr_distance * sizeof (guint32)); + calculated_lr = (guint32) (fixture->aw.pc + + (bs->expected_lr_distance * sizeof (guint32))); *((guint32 *) (bs->expected_output + bs->lr_offset)) = GUINT32_TO_LE (calculated_lr); } diff --git a/tests/gum-tests.vcxproj b/tests/gum-tests.vcxproj index f0b94da31..40b752101 100644 --- a/tests/gum-tests.vcxproj +++ b/tests/gum-tests.vcxproj @@ -87,7 +87,7 @@ - .;.\stubs;..;..\gum;..\gum\arch-x86;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-32;$(IntDir)..\gum-32\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) + .;.\stubs;..;..\gum;..\gum\arch-x86;..\gum\arch-arm;..\gum\arch-arm64;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-32;$(IntDir)..\gum-32\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) GUM_STATIC;HAVE_I386=1;HAVE_WINDOWS=1;HAVE_ASSERT_H=1;HAVE_STRING_H=1;HAVE_V8=1;HAVE_SYMBOL_BACKEND=1;HAVE_LIBS=1;HAVE_BINDINGS=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4100;4152;4210;%(DisableSpecificWarnings) @@ -107,7 +107,7 @@ copy /B /Y "$(SolutionDir)build\frida-windows\$(Platform)-$(ConfigurationName)\b - .;.\stubs;..;..\gum;..\gum\arch-x86;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-64;$(IntDir)..\gum-64\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) + .;.\stubs;..;..\gum;..\gum\arch-x86;..\gum\arch-arm;..\gum\arch-arm64;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-64;$(IntDir)..\gum-64\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) GUM_STATIC;HAVE_I386=1;HAVE_WINDOWS=1;HAVE_ASSERT_H=1;HAVE_STRING_H=1;HAVE_V8=1;HAVE_SYMBOL_BACKEND=1;HAVE_LIBS=1;HAVE_BINDINGS=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4100;4152;4210;%(DisableSpecificWarnings) @@ -127,7 +127,7 @@ copy /B /Y "$(SolutionDir)build\frida-windows\$(Platform)-$(ConfigurationName)\b - .;.\stubs;..;..\gum;..\gum\arch-x86;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-32;$(IntDir)..\gum-32\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) + .;.\stubs;..;..\gum;..\gum\arch-x86;..\gum\arch-arm;..\gum\arch-arm64;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-32;$(IntDir)..\gum-32\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) GUM_STATIC;HAVE_I386=1;HAVE_WINDOWS=1;HAVE_ASSERT_H=1;HAVE_STRING_H=1;HAVE_V8=1;HAVE_SYMBOL_BACKEND=1;HAVE_LIBS=1;HAVE_BINDINGS=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4100;4152;4210;%(DisableSpecificWarnings) @@ -147,7 +147,7 @@ copy /B /Y "$(SolutionDir)build\frida-windows\$(Platform)-$(ConfigurationName)\b - .;.\stubs;..;..\gum;..\gum\arch-x86;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-64;$(IntDir)..\gum-64\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) + .;.\stubs;..;..\gum;..\gum\arch-x86;..\gum\arch-arm;..\gum\arch-arm64;..\libs;..\libs\gum\heap;..\libs\gum\prof;..\bindings\gumpp;$(IntDir)..\gum-64;$(IntDir)..\gum-64\libudis86;$(SolutionDir)udis86;%(AdditionalIncludeDirectories) GUM_STATIC;HAVE_I386=1;HAVE_WINDOWS=1;HAVE_ASSERT_H=1;HAVE_STRING_H=1;HAVE_V8=1;HAVE_SYMBOL_BACKEND=1;HAVE_LIBS=1;HAVE_BINDINGS=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4100;4152;4210;%(DisableSpecificWarnings) @@ -174,6 +174,48 @@ copy /B /Y "$(SolutionDir)build\frida-windows\$(Platform)-$(ConfigurationName)\b + + true + true + true + true + + + + true + true + true + true + + + + true + true + true + true + + + + true + true + true + true + + + + true + true + true + true + + + + true + true + true + true + + true true @@ -345,4 +387,4 @@ copy /B /Y "$(SolutionDir)build\frida-windows\$(Platform)-$(ConfigurationName)\b - + \ No newline at end of file diff --git a/tests/gum-tests.vcxproj.filters b/tests/gum-tests.vcxproj.filters index 4de0dd281..a97a7461a 100644 --- a/tests/gum-tests.vcxproj.filters +++ b/tests/gum-tests.vcxproj.filters @@ -37,6 +37,12 @@ {d5b54bac-c4d7-454d-b175-74936806c670} + + {945f9b08-f2a1-406e-8c5a-dfedfa55adeb} + + + {6378022e-45dd-4fb7-a3b4-6e107a63a6e4} + @@ -177,6 +183,42 @@ Tests\core + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm + + + Tests\core\arch-arm64 + + + Tests\core\arch-arm64 + + + Tests\core\arch-arm64 + + + Tests\core\arch-arm64 + @@ -198,4 +240,4 @@ Tests\prof\stubs - + \ No newline at end of file diff --git a/tests/gumtest.c b/tests/gumtest.c index 9c43f397e..cb3a68d38 100644 --- a/tests/gumtest.c +++ b/tests/gumtest.c @@ -103,12 +103,10 @@ main (gint argc, gchar * argv[]) TEST_RUN_LIST (symbolutil); TEST_RUN_LIST (codewriter); TEST_RUN_LIST (relocator); -#ifndef G_OS_WIN32 /* TODO: build system */ TEST_RUN_LIST (armwriter); TEST_RUN_LIST (armrelocator); TEST_RUN_LIST (thumbwriter); TEST_RUN_LIST (thumbrelocator); -#endif TEST_RUN_LIST (arm64writer); TEST_RUN_LIST (arm64relocator); TEST_RUN_LIST (interceptor);