TransWikia.com

Analyze stack with IDAPython

Reverse Engineering Asked by func on January 27, 2021

In Ida pseudo-code when I press at stack’s variable I can see the place of this variable in stack.

char buffer[XXX]; // [sp+YYh]

How can I get that information (buffer size and place of this buffer in stack) in IDAPython?

One Answer

You can do this using idapython - using ida_hexrays api:

ida_hexrays.init_hexrays_plugin()
for var in ida_hexrays.decompile(ea).get_lvars():
    # offset
    offset = -stack_size + var.get_stkoff()
    # variable size
    size = var.width
    # variable type
    type = var.tif

And in ida gui, you can see the comments beside declarations.

enter image description here

Answered by R4444 on January 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP