-> The _ReturnAddress intrinsic provides the address of the instruction in the calling function that will be executed after control returns to the caller.
C++:
Code: Select all
_ReturnAddress()
http://msdn.microsoft.com/en-us/library ... s.80).aspx
Code: Select all
_ReturnAddress()
Code: Select all
Procedure Test(Param1.i, Param2.i)
Protected ReturnAddr.i
!mov eax, [esp+4]
!mov [p.v_ReturnAddr], eax
MessageRequester("return addr", Hex(ReturnAddr))
EndProcedure
Test(15, 17)
Code: Select all
Macro MyTest
Debug MacroExpandedCount
x = ?MyLabel#MacroExpandedCount
MyLabel#MacroExpandedCount:
EndMacro
MyTest
Debug x ; address beyond last macro instruction for 1st use
MyTest
Debug x ; address beyond last macro instruction for 2nd use
MyTest
Debug x ; address beyond last macro instruction for 3rd use
He wants the return address, i guess without knowing the caller, so he cant place a macro in the caller.buddymatkona wrote:Instead of an Inline Function, how about a Macro?
Code: Select all
Procedure TEST0(xyz,a,b,c,d,e,f)
x = 0
MOV eax, [esp+36]
MOV x, eax
Debug (x)
EndProcedure
Procedure TEST1()
TEST0(1,2,3,4,5,6,7)
EndProcedure
Procedure TEST2()
V = 1000
V = V - 200
TEST0(1,2,3,4,5,6,7)
EndProcedure
Procedure TEST3()
TEST1()
EndProcedure
TEST0(1,2,3,4,5,6,7)
TEST2()
TEST3()
TEST3()
TEST2()
TEST2()
TEST0(1,2,3,4,5,6,7)
TEST1()
TEST1()
Code: Select all
Procedure TEST0(xyz,a,b,c,d,e,f)
x = 0
MOV eax, esp
MOV x, eax
Debug (x)
EndProcedure
Procedure TEST1()
TEST0(1,2,3,4,5,6,7)
EndProcedure
Procedure TEST2()
V = 1000
V = V - 200
TEST0(1,2,3,4,5,6,7)
EndProcedure
Procedure TEST3()
TEST1()
EndProcedure
TEST0(1,2,3,4,5,6,7)
TEST2()
TEST3()
TEST3()
TEST2()
TEST2()
TEST0(1,2,3,4,5,6,7)
TEST1()
TEST1()
Code: Select all
Global ReturnAddress
!Macro RET val {
!mov ecx ,[esp]
!mov [v_ReturnAddress], ecx
!ret val
!}
Procedure Foo(a.i,b.i)
Protected c ,d
ProcedureReturn a * b
EndProcedure
Debug foo(3,4)
Debug @foo()
Debug ReturnAddress
Thx Thorium,Thorium wrote:ESP is the stack pointer, it holds the stack address.
If a call is invoked the return address is pushed on the stack, so after a call ESP points to the stack position the return address is stored.
[esp+36] in TEST0 is wrong. Only add localy declared variables, not parameter variables.
I dont get what you want to accomplish with TEST1, TEST2 and TEST3.