aboutsummaryrefslogtreecommitdiff
path: root/frida_mode/src/stats
diff options
context:
space:
mode:
Diffstat (limited to 'frida_mode/src/stats')
-rw-r--r--frida_mode/src/stats/stats.c24
-rw-r--r--frida_mode/src/stats/stats_arm64.c21
-rw-r--r--frida_mode/src/stats/stats_x86_64.c21
3 files changed, 7 insertions, 59 deletions
diff --git a/frida_mode/src/stats/stats.c b/frida_mode/src/stats/stats.c
index af08cd71..1d3520bc 100644
--- a/frida_mode/src/stats/stats.c
+++ b/frida_mode/src/stats/stats.c
@@ -2,17 +2,16 @@
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
-#include <sys/shm.h>
#include <sys/mman.h>
#include "frida-gumjs.h"
#include "config.h"
-#include "util.h"
-
#include "entry.h"
+#include "shm.h"
#include "stalker.h"
#include "stats.h"
+#include "util.h"
#define MICRO_TO_SEC 1000000
@@ -360,27 +359,10 @@ void stats_init(void) {
g_free(path);
- int shm_id =
- shmget(IPC_PRIVATE, sizeof(stats_data_t), IPC_CREAT | IPC_EXCL | 0600);
- if (shm_id < 0) { FFATAL("shm_id < 0 - errno: %d\n", errno); }
-
- stats_data = shmat(shm_id, NULL, 0);
- g_assert(stats_data != MAP_FAILED);
-
GumStalkerObserver *observer = stalker_get_observer();
stats_observer_init(observer);
- /*
- * Configure the shared memory region to be removed once the process dies.
- */
- if (shmctl(shm_id, IPC_RMID, NULL) < 0) {
-
- FFATAL("shmctl (IPC_RMID) < 0 - errno: %d\n", errno);
-
- }
-
- /* Clear it, not sure it's necessary, just seems like good practice */
- memset(stats_data, '\0', sizeof(stats_data_t));
+ stats_data = shm_create(sizeof(stats_data_t));
starts_arch_init();
diff --git a/frida_mode/src/stats/stats_arm64.c b/frida_mode/src/stats/stats_arm64.c
index 313ab47a..ea283dbe 100644
--- a/frida_mode/src/stats/stats_arm64.c
+++ b/frida_mode/src/stats/stats_arm64.c
@@ -1,9 +1,9 @@
-#include <sys/shm.h>
#include <sys/mman.h>
#include "frida-gumjs.h"
#include "ranges.h"
+#include "shm.h"
#include "stats.h"
#include "util.h"
@@ -44,24 +44,7 @@ static stats_data_arch_t *stats_data_arch = NULL;
void starts_arch_init(void) {
- int shm_id = shmget(IPC_PRIVATE, sizeof(stats_data_arch_t),
- IPC_CREAT | IPC_EXCL | 0600);
- if (shm_id < 0) { FFATAL("shm_id < 0 - errno: %d\n", errno); }
-
- stats_data_arch = shmat(shm_id, NULL, 0);
- g_assert(stats_data_arch != MAP_FAILED);
-
- /*
- * Configure the shared memory region to be removed once the process dies.
- */
- if (shmctl(shm_id, IPC_RMID, NULL) < 0) {
-
- FFATAL("shmctl (IPC_RMID) < 0 - errno: %d\n", errno);
-
- }
-
- /* Clear it, not sure it's necessary, just seems like good practice */
- memset(stats_data_arch, '\0', sizeof(stats_data_arch_t));
+ stats_data_arch = shm_create(sizeof(stats_data_arch_t));
}
diff --git a/frida_mode/src/stats/stats_x86_64.c b/frida_mode/src/stats/stats_x86_64.c
index 761ca133..e2fb7b80 100644
--- a/frida_mode/src/stats/stats_x86_64.c
+++ b/frida_mode/src/stats/stats_x86_64.c
@@ -1,9 +1,9 @@
-#include <sys/shm.h>
#include <sys/mman.h>
#include "frida-gumjs.h"
#include "ranges.h"
+#include "shm.h"
#include "stats.h"
#include "util.h"
@@ -46,24 +46,7 @@ static stats_data_arch_t *stats_data_arch = NULL;
void starts_arch_init(void) {
- int shm_id = shmget(IPC_PRIVATE, sizeof(stats_data_arch_t),
- IPC_CREAT | IPC_EXCL | 0600);
- if (shm_id < 0) { FFATAL("shm_id < 0 - errno: %d\n", errno); }
-
- stats_data_arch = shmat(shm_id, NULL, 0);
- g_assert(stats_data_arch != MAP_FAILED);
-
- /*
- * Configure the shared memory region to be removed once the process dies.
- */
- if (shmctl(shm_id, IPC_RMID, NULL) < 0) {
-
- FFATAL("shmctl (IPC_RMID) < 0 - errno: %d\n", errno);
-
- }
-
- /* Clear it, not sure it's necessary, just seems like good practice */
- memset(stats_data_arch, '\0', sizeof(stats_data_arch_t));
+ stats_data_arch = shm_create(sizeof(stats_data_arch_t));
}