Hahah .. I am now posting the basic for the function local variable in assembly. Local varible is a variable where only be used just within the function and its operation. Lets see an example C code below
Then we can load the exe to IDA. We can jump straight to the check function that as follow
We can see the above picture. After the function prologue there is additional assembly code that is sub esp, 10h this code actually creating the stack space as much as 16 bytes or 10h to contain all the variables int = 4 bytes, sinve we have 2 local variable then we need at least 2 x 4 bytes = 8. But since we compile it in debug mode then compiler spare some space to it
We can see from the above ilustration EBP is the reference point for accessing the variable in the stack.
The convension is for local variable must be assigned to lower memory address or from the picture above is local variable is at the top of EBP where to access it will be EBP-XX where XX is the number of bytes required.
So for example we want to access height variable then we need to do EBP+(-8) or accessing width using EBP+(-4)
but usually if you load to IDA then it will help creating like macro to change the instructio more readble
so to access the variable EBP will be added by the macro then it will use EBP+width or EBP+height
we can see on the above assembly code that the we are assigning value to heigh and width using below code
I will post the explanation for variable that is passed to the function in the next post