You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB
C

//this file to be compiled as a shared object
#define _GNU_SOURCE
//linux
#include <stdlib.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/uio.h>
static void *addr;
static pid_t pid;
static long long value;
struct iovec local[1];
struct iovec remote[1];
void set_pid(pid_t p) {
pid = p;
}
//value to compare against
void set_value(long long val) {
value = val;
}
bool scan(void *addr, size_t type) {
long long values[1];
local[0].iov_base = values;
local[0].iov_len = sizeof(long long); //may or may not get extra values
remote[0].iov_base = addr;
remote[0].iov_len = local[0].iov_len;
process_vm_readv(pid, local, 1, remote, 1, 0);
//write your comparison function here
//switch on type to trim possible garbage data
switch(type) {
case sizeof(char):
if ((char)value == (char)values[0]) {return true;} break;
if ((short)value == (short)values[0]) {return true;} break;
if ((int)value == (int)values[0]) {return true;} break;
if ((long)value == (long)values[0]) {return true;} break;
}
return false;
}