about summary refs log tree commit diff
path: root/frida_mode/src/instrument/instrument_arm32.c
blob: 4525e83d34969b221ba764cdeab5f6d883f6817e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "frida-gumjs.h"

#include "instrument.h"
#include "util.h"

#if defined(__arm__)

gboolean instrument_cache_enabled = FALSE;
gsize    instrument_cache_size = 0;

gboolean instrument_is_coverage_optimize_supported(void) {

  return false;

}

void instrument_coverage_optimize(const cs_insn    *instr,
                                  GumStalkerOutput *output) {

  UNUSED_PARAMETER(instr);
  UNUSED_PARAMETER(output);
  FFATAL("Optimized coverage not supported on this architecture");

}

void instrument_coverage_optimize_insn(const cs_insn    *instr,
                                       GumStalkerOutput *output) {

  UNUSED_PARAMETER(instr);
  UNUSED_PARAMETER(output);
  FFATAL("Optimized coverage not supported on this architecture");

}

void instrument_coverage_optimize_init(void) {

  FWARNF("Optimized coverage not supported on this architecture");

}

void instrument_flush(GumStalkerOutput *output) {

  if (output->encoding == GUM_INSTRUCTION_SPECIAL) {

    gum_thumb_writer_flush(output->writer.thumb);

  } else {

    gum_arm_writer_flush(output->writer.arm);

  }

}

gpointer instrument_cur(GumStalkerOutput *output) {

  return gum_arm_writer_cur(output->writer.arm);

}

void instrument_cache_config(void) {

}

void instrument_cache_init(void) {

}

void instrument_cache_insert(gpointer real_address, gpointer code_address) {

  UNUSED_PARAMETER(real_address);
  UNUSED_PARAMETER(code_address);

}

void instrument_cache(const cs_insn *instr, GumStalkerOutput *output) {

  UNUSED_PARAMETER(instr);
  UNUSED_PARAMETER(output);

}

void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {

  int fd = (int)user_data;
  instrument_regs_format(fd,
                         "r0 : 0x%08x, r1 : 0x%08x, r2 : 0x%08x, r3 : 0x%08x\n",
                         cpu_context->r[0], cpu_context->r[2],
                         cpu_context->r[1], cpu_context->r[3]);
  instrument_regs_format(fd,
                         "r4 : 0x%08x, r5 : 0x%08x, r6 : 0x%08x, r7 : 0x%08x\n",
                         cpu_context->r[4], cpu_context->r[5],
                         cpu_context->r[6], cpu_context->r[7]);
  instrument_regs_format(
      fd, "r8 : 0x%08x, r9 : 0x%08x, r10: 0x%08x, r11: 0x%08x\n",
      cpu_context->r8, cpu_context->r9, cpu_context->r10, cpu_context->r11);
  instrument_regs_format(
      fd, "r12: 0x%08x, sp : 0x%08x, lr : 0x%08x, pc : 0x%08x\n",
      cpu_context->r12, cpu_context->sp, cpu_context->lr, cpu_context->pc);
  instrument_regs_format(fd, "cpsr: 0x%08x\n\n", cpu_context->cpsr);

}

#endif