about summary refs log tree commit diff
path: root/frida_mode/src/entry.c
blob: e71386a083ea41e759c061e621fd7f72aca0276e (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
#include "frida-gum.h"

#include "debug.h"

#include "entry.h"
#include "instrument.h"
#include "stalker.h"
#include "util.h"

extern void __afl_manual_init();

guint64 entry_start = 0;

static void entry_launch(void) {

  __afl_manual_init();

  /* Child here */
  previous_pc = 0;

}

void entry_init(void) {

  entry_start = util_read_address("AFL_ENTRYPOINT");
  OKF("entry_point: 0x%016" G_GINT64_MODIFIER "X", entry_start);

}

void entry_run(void) {

  if (entry_start == 0) { entry_launch(); }

}

static void entry_callout(GumCpuContext *cpu_context, gpointer user_data) {

  UNUSED_PARAMETER(cpu_context);
  UNUSED_PARAMETER(user_data);
  entry_launch();

}

void entry_prologue(GumStalkerIterator *iterator, GumStalkerOutput *output) {

  UNUSED_PARAMETER(output);
  gum_stalker_iterator_put_callout(iterator, entry_callout, NULL, NULL);

}