0

I’m trying to set a function chunk end at a certain EA in a function using my Ida python plugin, but I can’t find any API which lets me do just that. set_func_end appear not to work (keeps returning false.). Basically I’m trying to simulate the action of pressing “E” at a certain EA. Appreciate any help, thanks in advance!

1 Answer 1

0
import ida_funcs
import ida_auto

funcEa = 0x08054FE1
newEndEa = 0x08054FF7

f = ida_funcs.get_func(funcEa)
f.end_ea = newEndEa
ida_funcs.update_func(f)
ida_funcs.reanalyze_function(f)
ida_auto.auto_wait()

In response to your edit, perhaps some basic safety precautions would help, as in:

f = ida_funcs.get_func(funcEa)
if f is not None:
    nChunk = ida_funcs.func_contains(f,newEndEa)
    if nChunk >= 0:
        if nChunk > 0:
            f = ida_funcs.getn_fchunk(nChunk)
        f.end_ea = newEndEa
        ida_funcs.update_func(f)
        ida_funcs.reanalyze_function(f)
        ida_auto.auto_wait()
4
  • Does'nt seem to work. causes IDA to crash Aug 31 at 9:05
  • The thread tried to read from or write to a virtual address for which it does not have the appropriate access. Aug 31 at 9:13
  • Seems like its working on other views, i cant seem to set this line: .text:00007FF7179EEDE5 jnb short near ptr loc_7FF7179EEE06+5 as function end. Aug 31 at 9:41
  • See edit for a solution with safety checking and which explicitly takes chunking into account. Aug 31 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.