SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 277 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"

This is done by allocating the memory within the .data or .bss section of
the process??™s memory. Remember, once allocated, the buffer is of fixed length. The
buffer may hold any predefined type of data; however, for our purpose, we will focus on
string-based buffers, used to store user input and variables.
Strings in Memory
Simply put, strings are just continuous arrays of character data in memory. The string is
referenced in memory by the address of the first character. The string is terminated or
ended by a null character (\0 in C).
Pointers
Pointers are special pieces of memory that hold the address of other pieces of memory.
Moving data around inside of memory is a relatively slow operation. It turns out that
instead of moving data, it is much easier to keep track of the location of items in memory
through pointers and simply change the pointers. Pointers are saved in 4 bytes of
contiguous memory because memory addresses are 32 bits in length (4 bytes). For
example, as mentioned, strings are referenced by the address of the first character in the
array. That address value is called a pointer. So the variable declaration of a string in C is
written as follows:
char * str; //this is read, give me 4 bytes called str which is a pointer
//to a Character variable (the first byte of the array).


Pages:
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289