PDA

View Full Version : Ida Python SegCreate problem


ZaiRoN
01-13-2006, 11:23 AM
Hi.
Playing a little with IDa Python I was trying to create a new segment using the function SegCreate. From Ida help you can read the syntax of the function:
Code:
success SegCreate(long startea,long endea,long base,long use32,long align,long comb);
where:
// startea - linear address of the start of the segment
// endea - linear address of the end of the segment
// this address will not belong to the segment
// 'endea' should be higher than 'startea'
// base - base paragraph or selector of the segment.
// a paragraph is 16byte memory chunk.
// If a selector value is specified, the selector should be
// already defined.
// use32 - 0: 16bit segment, 1: 32bit segment, 2: 64bit segment
// align - segment alignment. see below for alignment values
// comb - segment combination. see below for combination values.
// returns: 0-failed, 1-ok

The definition of the function taken from idc.py is almost the same:
Code:
def SegCreate(startea, endea, base, use32, align, comb)
so I tried to use:
Code:
SegCreate(0x610000, 0x620000, 0x1, 0x1, 0x2, 0x2)
Unfortunatly I received an error... So, looking at the definition of the function -inside ida.py- I noticed something strange:
Code:
def SegCreate(startea, endea, base, use32, align, comb):
...
success = idaapi.add_segm(startea, endea, para, "Segment", "CODE"
...
Look at the third parameter: para
This is an error, 'para' is never defined/used/referred before. The right parameter should be 'base'; I tried to change the parameters but I got a warning message, this time from ida:
"Create a segment (00620000-00000001): end address is lower than start address."
Seems like there is something wrong with the order of the parameters. The right sequence is base-startea-endea.

I mailed the author but I didn't receive a reply so I decided to write it here. Is there someone that had the same problem?

Regards,
ZaiRoN

ZaiRoN
01-24-2006, 05:38 PM
Just to let you know Ida Python 0.8.0 is out at the same address: http://www.d-dome.net/idapython/
The segcreate problem is still alive but the author resolved the problem fixing the file idc.py; he 'll upload the new version sooner. I have the updated file which I won't upload here until Dyce will give me the authorization, but if you have any kind of problems with the function don't esitate to contact me.

Regards,
ZaiRoN

Opcode
01-24-2006, 05:50 PM
Thanks, Zairon.

This thread has awaken my attention to IDA Python.
I think that this is a good opportunity to me to start learning Python.

Regards,
Opcode

ZaiRoN
01-25-2006, 12:56 PM
Hi Opcode.
If you use idc, ida python it's a must