Monday, 19 August 2013

Finding Allocated Memory

Finding Allocated Memory

Platform: x86 Linux 3.2.0 (Debian 7.1)
Compiler: GCC 4.7.2 (Debian 4.7.2-5)
I am writing a function that generates a "random" integer by reading
allocated portions of memory for "random" values. The idea is based on the
fact that uninitialized variables have undefined values. My initial idea
was to allocate an array using malloc() and then use it's uninitialized
elements to generate a random number. But malloc() tends to return NULL
blocks of memory so I cannot guarantee that there is anything to read. So
I thought about reading a separate processes memory in order to almost
guarantee values other than NULL. My current idea is somehow finding the
first valid memory address and reading from there down but I do not know
how to do this. I tried initializing a pointer to NULL and then
incrementing it by one but if I attempt to print the referenced memory
location a segmentation fault occurs. So my question is how do I read a
separate processes memory. I do not need to do anything with the memory
other than read it.

No comments:

Post a Comment