about summary refs log tree commit diff
path: root/frida_mode/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'frida_mode/src/util.c')
-rw-r--r--frida_mode/src/util.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/frida_mode/src/util.c b/frida_mode/src/util.c
index 09e8a58b..d84b7065 100644
--- a/frida_mode/src/util.c
+++ b/frida_mode/src/util.c
@@ -1,7 +1,5 @@
 #include "util.h"
 
-#include "debug.h"
-
 guint64 util_read_address(char *key) {
 
   char *value_str = getenv(key);
@@ -66,3 +64,40 @@ guint64 util_read_num(char *key) {
 
 }
 
+gboolean util_output_enabled(void) {
+
+  static gboolean initialized = FALSE;
+  static gboolean enabled = TRUE;
+
+  if (!initialized) {
+
+    initialized = TRUE;
+    if (getenv("AFL_DEBUG_CHILD") == NULL) { enabled = FALSE; }
+
+  }
+
+  return enabled;
+
+}
+
+gsize util_rotate(gsize val, gsize shift, gsize size) {
+
+  if (shift == 0) { return val; }
+  gsize result = ((val >> shift) | (val << (size - shift)));
+  result = result & ((1 << size) - 1);
+  return result;
+
+}
+
+gsize util_log2(gsize val) {
+
+  for (gsize i = 0; i < 64; i++) {
+
+    if (((gsize)1 << i) == val) { return i; }
+
+  }
+
+  FFATAL("Not a power of two");
+
+}
+