| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Nov 15, 2016 8:07 pm Post subject: "Return Address" and "Parameters" in Mem |
|
|
Please take a look at the following screenshot.
I want to know what " Return Address" and "Parameters" mean in Memory Viewer.
1. Does "Return Address" indicate the address of the calling function (caller)?
2. Does "Parameters" indicate the parameters in the calling function, which is at the location of "Return Address"?
Thanks a lot.
| Description: |
|
| Filesize: |
30.68 KB |
| Viewed: |
5939 Time(s) |

|
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 155
Joined: 06 Jul 2014 Posts: 4758
|
Posted: Tue Nov 15, 2016 9:04 pm Post subject: |
|
|
They're based on standard calling conventions of subroutines that establish their own stack frames. The return address is the address the current subroutine may return to, and the parameters are possible arguments that were passed to the subroutine.
Of course, they don't have to be correct. Smaller subroutines don't need to establish a stack frame and are free to use the ebp register for other purposes.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Nov 15, 2016 9:25 pm Post subject: |
|
|
| ParkourPenguin wrote: | They're based on standard calling conventions of subroutines that establish their own stack frames. The return address is the address the current subroutine may return to, and the parameters are possible arguments that were passed to the subroutine.
Of course, they don't have to be correct. Smaller subroutines don't need to establish a stack frame and are free to use the ebp register for other purposes. |
Thanks, Penguin. So if I understand correctly:
1. The parameters will be passed from the current subroutine to whatever is at the return address, right?
2. Why are there so many return addresses? Does the first return address return to the second return address in the list?
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 155
Joined: 06 Jul 2014 Posts: 4758
|
Posted: Tue Nov 15, 2016 9:50 pm Post subject: |
|
|
That is not what a parameter is. A parameter/argument (more or less refers to the same thing) is a value passed to the subroutine by the caller. They are sometimes passed through registers (e.g. fastcall, x64 calling conventions), but are commonly passed through the stack (e.g. stdcall, cdecl). The value that is returned by the subroutine to the caller is passed almost exclusively through the eax register (rax for x64, sometimes st(0) for x87 or xmm0 for SSE).
There are so many return addresses because functions can call other functions.
| Code: | function f1()
...
end
function f2()
f1()
end
function f3()
f2()
end |
In the above Lua example, f3 will call f2 which in turn calls f1. In such a case, f1 will return to f2 which will then return to f3.
Perhaps you should learn the basics of a higher-level language first so that you are more familiar with common programming terminology (such as "parameter") and mechanics (how to use functions).
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Nov 15, 2016 10:27 pm Post subject: |
|
|
| ParkourPenguin wrote: | That is not what a parameter is. A parameter/argument (more or less refers to the same thing) is a value passed to the subroutine by the caller. They are sometimes passed through registers (e.g. fastcall, x64 calling conventions), but are commonly passed through the stack (e.g. stdcall, cdecl). The value that is returned by the subroutine to the caller is passed almost exclusively through the eax register (rax for x64, sometimes st(0) for x87 or xmm0 for SSE).
There are so many return addresses because functions can call other functions.
| Code: | function f1()
...
end
function f2()
f1()
end
function f3()
f2()
end |
In the above Lua example, f3 will call f2 which in turn calls f1. In such a case, f1 will return to f2 which will then return to f3.
Perhaps you should learn the basics of a higher-level language first so that you are more familiar with common programming terminology (such as "parameter") and mechanics (how to use functions). |
Oh, got it. my brain wasn't functioning and asked a stupid question. Thanks.
|
|
| Back to top |
|
 |
|