Root > Reference > All Functions > GetFunctionSize

Function GetFunctionSize

Previous pageReturn to chapter overviewNext page   

Returns size of the function in bytes.

 

Unit

EDisAsm

 

Syntax

 

Code (Delphi)

function GetFunctionSize(

const AAddr: Pointer;

const AMaxSize: Cardinal

): Cardinal;

 

Parameters

AAddr

A pointer to function.

 

AMaxSize

Maximum possible size to scan. Use this to limit scan area and prevent unlimited reading.

 

Return value

Size of function at AAddr in bytes. This value is always in range 0..AMaxSize.

 

Exceptions

System.SysUtils.EAccessViolation

Invalid address or invalid code.

 

Remarks

GetFunctionSize scans machine code at AAddr address up to AAddr + AMaxSize. It stops at first ret instrution and returns distance between AAddr and end of ret.

 

This function is used in hooks and disassembler-related code.

 

Note

Make sure that you pass a pointer to a real function. Not to some arbitrary code or function's stub.

 

Use to get pointer to real code from stub.

 

Warning

This is heuristic function. Results are not 100% reliable.

 

See also

GetAsmSize



Send feedback... Build date: 2024-12-19
Last edited: 2024-12-19
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_edisasm_getfunctionsize.php