xzlwbl / idapython

Automatically exported from code.google.com/p/idapython
Other
0 stars 0 forks source link

isByte/isWord/... are wrong #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found this when I couldn't get isAlign to work.

isByte and friends are implemented as:
def is...(F):     return (isData(F) & (F & DT_TYPE) == FF_...)

That really means ((isData(F) & F & DT_TYPE) == FF_...) which is 
completely wrong.

They should all be
def is...(F):     return (isData(F) and (F & DT_TYPE) == FF_...)

Also, FF_ALIGN is defined as -0x50000000 in IDAPython, but GetFlags 
returns an unsigned number just like in IDC. FF_* should probably be 
unsigned as well. I fixed this by hacking idaapi.py since I can't be 
bothered to learn SWIG right now.

Original issue reported on code.google.com by goo...@simon.user.lysator.liu.se on 9 Dec 2008 at 11:35

GoogleCodeExporter commented 9 years ago
The is* functions are now fixed.
It appears that SWIG casts #define constants to long and the ones over 
0x80000000 turn negative.
Masking them back to 32 bits fixed these too.

Most surprising is that nobody had bumped into this earlier. Good catch!

Thanks for the report!

Original comment by gergely.erdelyi on 10 Dec 2008 at 2:59