#define _GNU_SOURCE /* the idea of the scanner is that you give it a memory address to watch and it reads from the address and if it matches the desired value, it sends a message to a controller ideally to detect a loading screen you would want to call the control function on a state change rather than every time the value matches */ //if linux #include #include #include #include //only watch one process at a time static pid_t pid; //control function static void (*callback)(void); int watch_memory(void *addr, int desired) { int values[1]; struct iovec local[1]; struct iovec remote[1]; local[0].iov_base = values; local[0].iov_len = 1 * sizeof(int); remote[0].iov_base = (void *) addr; remote[0].iov_len = 1 * sizeof(int); int nread = process_vm_readv(pid, local, 4, remote, 4, 0); if (desired == values[0]) { //printf("%d %d\n", values[0], desired); callback(); } return values[0]; } void set_control_func(void (*c)(void)) { callback = c; } void set_pid(pid_t p) { pid = p; }