Variables
Files used -> 2-localvar.c, 2-localvar.exe, 2-1-globalvar.c, 2-1-globalvar.exe
Last updated
Files used -> 2-localvar.c, 2-localvar.exe, 2-1-globalvar.c, 2-1-globalvar.exe
Last updated
Compiling the file with cl.exe and loading the compiled file in IDA and moving to main function by looking at multiple push instructions followed by cal to a function which will be our main function .
Located push instructions and subsequent call to a function.Double Click to look into it.
Here, we will keep not of how local variables are access/stored. Currently, our two variables are referenced by stack address (ebp+var_4, ebp+var_8). Where 4 and 8 are showing the size of variable. Integer variables have 4 bytes size. So first variable is named var_4 and second variable 4 bytes after var_4 i.e. var_8.
From stack then they are pushed on to the top of stack as argument for printf.
Rest things are same, prologue, epilogue, return 0 and restoring of stack frame.
Here, if we see that the variable is referenced as memory address. dword_419000 means value stored at address 0x419000
And rest things are same.
Local Variables are referenced with stack address, ebp+var_4.
Global Variables are referenced with memory address, dword_419000 i.e. address 0x419000.