mxmssh / idapython

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

Chooser bad column name #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create any chooser.
2.
3.

What is the expected output? What do you see instead?
The column name in the list should be a parameter for the chooser.
Instead the name of last item in the list is chosen as the column
name.
To overcome this I add a dummy item and ignore if it is chosen. 

What version of the product are you using? On what operating system?
0.9.0

Please provide any additional information below.

Original issue reported on code.google.com by stam.co...@gmail.com on 2 Jul 2008 at 7:49

GoogleCodeExporter commented 9 years ago
As far as I can tell that seems to be the way choose() works in IDA. The 
parameter passed
in 'title' becomes the title of the chooser window but only in the GUI version. 
It is indeed
quite weird that IDA takes the last item and makes it the column title.

One way to work around this is to subclass Choose() and override sizer() to 
return len(self.list)-1 so the last item does not show up in the list.

Original comment by gergely.erdelyi on 2 Jul 2008 at 8:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

The following code works without any problem..

################

int data[] = { 1,2,3,0};
int widths[] = {16,16,16};

char *headers[] = {"Test 1","Test 2","Test 3"};
char *formats[] = { "%d","%d","%d"};

ulong idaapi my_sizer(void *obj)
{
    int *p = (int *)obj;
    int i = 0;

    while (*p++) 
        i++;

    return i;

}

void idaapi my_getline(void *obj,ulong n, char* const *cells)
{
    int *p = (int *)obj;

    if (n == 0)
    {
        for(int i = 0; i < 3; i++)
            qstrncpy(cells[i],headers[i],widths[i]);

    }
    else 
    {
        for (int i = 0; i < 3; i++)
            qsnprintf(cells[i],widths[i],formats[i],p[n - 1]);

    }
}

void run(int arg)
{
    choose2(data,3,widths,my_sizer,my_getline,"Testing 123");
}

Original comment by zarulsha...@gmail.com on 8 Dec 2008 at 9:54

GoogleCodeExporter commented 9 years ago
Okie, 

Gergely fixed both the header and the "string only" problem. Thanks!

http://code.google.com/p/idapython/source/detail?r=129

Original comment by zarulsha...@gmail.com on 10 Dec 2008 at 11:40

GoogleCodeExporter commented 9 years ago

Original comment by gergely.erdelyi on 10 Dec 2008 at 11:44