Root > Reference > All Functions > ConvertRetAddr

Function ConvertRetAddr

Previous pageReturn to chapter overviewNext page   

Convert return address to instruction pointer.

 

Unit

ELowLevel

 

Syntax

 

Code (Delphi)

function ConvertRetAddr(

const AReturnAddr: Pointer

): Pointer;

 

Parameters

AReturnAddr [in]

Return address. It is usually obtained by analyzing call stack or via ReturnAddress.

 

Return value

Pointer to CALL opcode. This value is always less than AReturnAddr.

 

Remarks

This routine is used for hooks.

 

If you have a return address and want to show/indicate caller - then you can use this function to convert return address to instruction pointer in caller's source. This function is needed because return address points to the next line in source file.

 

Function doesn't raise access violation in case of unavailable memory.

 

Warning

Function does NOT check if the AReturnAddr is a valid return address. Do not pass arbitrary pointers, pass return addresses only.

 

Note

This is a wrapper for EDisAsm.GetAddrByRetAddr function.

 

Examples

 

Code (Delphi)

var

P: Pointer;

begin

P := ReturnAddress; // P is a return address to caller (e.g. next line)

P := ConvertRetAddr(P); // Now P points to the exact caller of this code

end;

 

See also

GetAddrByRetAddr
GetTargetAddrByCallAddr



Send feedback... Build date: 2023-09-11
Last edited: 2023-09-11
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_elowlevel_convertretaddr.php