Some compilers will add useless bytes in functions or in between functions. In the below block of code at 0040117C we can see the "align" keyword that was inserted by IDA.
.text:00401176 mov eax, [edx+4]
.text:00401179 call eax
.text:0040117B
.text:0040117B locret_40117B: ; CODE XREF: sub_401160+Dj
.text:0040117B retn
.text:0040117B sub_401160 endp
.text:0040117B
.text:0040117B ; ---------------------------------------------------------------------------
.text:0040117C align 10h
.text:00401180
.text:00401180 ; =============== S U B R O U T I N E =======================================
.text:00401180
.text:00401180 ; Attributes: bp-based frame
.text:00401180
.text:00401180 ; int __stdcall sub_401180(void *Src)
If we were to view this in hex mode in this example we would see "CC CC ..
". With other compilers we might see "90 90 ..
". The obvious hint of what this is being used for is the "align" keyword.
Question: how can I tell if a specific byte at an address is marked as align
in IDAPython? Example code would be appreciated.
I have found a couple of functions and data types such as FF_ALIGN
and idaapi.is_align_insn(ea
that looked positive but I have yet to figure out a working example or results that confirm yes or no. I would prefer to rely on IDA types or functions rather than use string parsing for the keyword "align".
isAlign(idaapi.getFlags(ScreenEA()))
?isHead
andprevHead
, those functions might help you find the "head" of the align directive (I haven't tested this, it's just a thought).