I'm trying to recreate a memory dumper in C. I would like to iterate over memory using pointers and load the value when accessible.
#include<stdlib.h>
#include<stdio.h>
int main()
{
unsigned long ptr = sizeof(long);
printf("%s\n", (char*)ptr); // gives memory violation error
return 0;
}
When I hit printf("%s\n", (char*)ptr)
it raises a memory violation exception.
Is there any way either to handle this exception or to know if a pointer is accessible?
Thanks.