Ghidra: Getting size of function in bytes via flat API

Created on 25 Jul 2019  路  1Comment  路  Source: NationalSecurityAgency/ghidra

So far my solution to this problem has been iterating through each address in the function address space and counting the number of bytes. However, if there's anyway where when dealing with function objects I could get the function size in bytes without needing to iterate over its address space that would be great!

Especially frustrating since "Function Size" is right there in the GUI, but I just can't figure out how to pull that out via the flat api.

Question

Most helpful comment

This is what the GUI is doing:

https://github.com/NationalSecurityAgency/ghidra/blob/8b67e3c1e506a8c6d89ae90b715acd1dff4cf9e4/Ghidra/Features/Base/src/main/java/ghidra/util/table/field/FunctionBodySizeTableColumn.java#L34

So you could do something like getFunctionAt(addr).getBody().getNumAddresses() from your script.

>All comments

This is what the GUI is doing:

https://github.com/NationalSecurityAgency/ghidra/blob/8b67e3c1e506a8c6d89ae90b715acd1dff4cf9e4/Ghidra/Features/Base/src/main/java/ghidra/util/table/field/FunctionBodySizeTableColumn.java#L34

So you could do something like getFunctionAt(addr).getBody().getNumAddresses() from your script.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

chibicitiberiu picture chibicitiberiu  路  3Comments

Merculous picture Merculous  路  3Comments

astrelsky picture astrelsky  路  3Comments

tambry picture tambry  路  3Comments