code_junkie

How can you efficiently check the VM mapping for an address?

Nov 11th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. bool is_address_valid(ADDRINT addr) {
  2. static int pagesize = getpagesize();
  3.  
  4. const void *foo = (const void *)(addr / pagesize * pagesize);
  5.  
  6. if (munlock(foo, 1) == -1) {
  7. fprintf(stderr, "munlock(%p=>%p, 1) failed: %sn", addr, foo,
  8. strerror(errno));
  9. return false;
  10. }
  11. return true;
  12. }
Add Comment
Please, Sign In to add comment