#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

int main (int argc, char **argv) {
  char proc_mem[4096];
  sprintf (proc_mem, "/proc/%d/mem", atoi(argv[1]));
  cout << proc_mem << endl;
  
  ifstream pmem (proc_mem);
  void * start;
  do  {
    pmem.read (proc_mem, sizeof (proc_mem));
    start = memmem ("FUBAR", 5, proc_mem, sizeof(proc_mem));
    if (start) {
      cout << "FUBAR found at " << start << endl;
      return 0;
    }
  } while (!pmem.eof() && pmem.good());
  cout << "FUBAR not found" << endl;
  return 0;
}
