Assembly Language for Beginners

(Jeff_L) #1

1.20. ARRAYS


Let’s trace further and see how it gets restored:


Figure 1.89:OllyDbg: restoring value of EBP

Indeed, how it could be different? The compiler may generate some additional code to check the index
value to be always in the array’s bounds (like in higher-level programming languages^132 ) but this makes
the code slower.


Writing beyond array bounds


OK, we read some values from the stackillegally, but what if we could write something to it?


Here is what we have got:


#include <stdio.h>


int main()
{
int a[20];
int i;


for (i=0; i<30; i++)
a[i]=i;

return 0;
};


(^132) Java, Python, etc.

Free download pdf