Module idaapi :: Class Form
[frames] | no frames]

Class Form

object --+
         |
        Form

Nested Classes
  NumericArgument
Argument representing various integer arguments (ushort, uint32, uint64, etc...)
  StringArgument
Argument representing a character buffer
  Control
  LabelControl
Base class for static label control
  StringLabel
String label control
  NumericLabel
Numeric label control
  GroupItemControl
Base class for group control items
  ChkGroupItemControl
Checkbox group item control
  RadGroupItemControl
Radiobox group item control
  GroupControl
Base class for group controls
  ChkGroupControl
Checkbox group control class.
  RadGroupControl
Radiobox group control class.
  InputControl
Generic form input control.
  NumericInput
A composite class serving as a base numeric input control class
  ColorInput
Color button input control
  StringInput
Base string input control class.
  FileInput
File Open/Save input control
  DirInput
Directory browsing control
  ButtonInput
Button control.
  FormChangeCb
Form change handler.
  EmbeddedChooserControl
Embedded chooser control.
Instance Methods
 
__init__(self, form, controls)
Contruct a Form class.
 
Free(self)
Frees all resources associated with a compiled form.
 
__getitem__(self, name)
Returns a control object by name
 
Add(self, name, ctrl, mkattr=True)
Low level function.
 
FindControlById(self, id)
Finds a control instance given its id
 
AddControls(self, controls, mkattr=True)
Adds controls from a dictionary.
 
CompileEx(self, form)
Low level function.
 
Compile(self)
Compiles a form and returns the form object (self) and the argument list.
 
Execute(self)
Displays a compiled form.
 
EnableField(self, ctrl, enable)
Enable or disable an input field
 
ShowField(self, ctrl, show)
Show or hide an input field
 
MoveField(self, ctrl, x, y, w, h)
Move/resize an input field
 
GetFocusedField(self)
Get currently focused input field.
 
SetFocusedField(self, ctrl)
Set currently focused input field
 
RefreshField(self, ctrl)
Refresh a field
 
GetControlValue(self, ctrl)
Returns the control's value depending on its type
 
SetControlValue(self, ctrl, value)
Set the control's value depending on its type

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods
 
fieldtype_to_ctype(tp, i64=False)
Factory method returning a ctype class corresponding to the field type string
 
ControlToFieldTypeIdAndSize(ctrl)
Converts a control object to a tuple containing the field id and the associated buffer size
Class Variables
  FT_ASCII = 'A'
Ascii string - char *
  FT_SEG = 'S'
Segment - sel_t *
  FT_HEX = 'N'
Hex number - uval_t *
  FT_SHEX = 'n'
Signed hex number - sval_t *
  FT_COLOR = 'K'
Color button - bgcolor_t *
  FT_ADDR = '$'
Address - ea_t *
  FT_UINT64 = 'L'
default base uint64 - uint64
  FT_INT64 = 'l'
default base int64 - int64
  FT_RAWHEX = 'M'
Hex number, no 0x prefix - uval_t *
  FT_FILE = 'f'
File browse - char * at least QMAXPATH
  FT_DEC = 'D'
Decimal number - sval_t *
  FT_OCT = 'O'
Octal number, C notation - sval_t *
  FT_BIN = 'Y'
Binary number, 0b prefix - sval_t *
  FT_CHAR = 'H'
Char value -- sval_t *
  FT_IDENT = 'I'
Identifier - char * at least MAXNAMELEN
  FT_BUTTON = 'B'
Button - def handler(code)
  FT_DIR = 'F'
Path to directory - char * at least QMAXPATH
  FT_TYPE = 'T'
Type declaration - char * at least MAXSTR
  FT_FORMCHG = '%/'
Form change callback - formchgcb_t
  FT_ECHOOSER = 'E'
Embedded chooser - idaapi.Choose2
  FT_CHKGRP = 'C'
  FT_CHKGRP2 = 'c'
  FT_RADGRP = 'R'
  FT_RADGRP2 = 'r'
Instance Variables
  title
The Form title.
Properties

Inherited from object: __class__

Method Details

__init__(self, form, controls)
(Constructor)

 

Contruct a Form class. This class wraps around AskUsingForm() and provides an easier / alternative syntax for describing forms. The form control names are wrapped inside the opening and closing curly braces and the control themselves are defined and instantiated via various form controls (subclasses of Form).

Parameters:
  • form - The form string
  • controls - A dictionary containing the control name as a _key_ and control object as _value_
Overrides: object.__init__

Free(self)

 

Frees all resources associated with a compiled form. Make sure you call this function when you finish using the form.

Add(self, name, ctrl, mkattr=True)

 

Low level function. Prefer AddControls() to this function. This function adds one control to the form.

Parameters:
  • name - Control name
  • ctrl - Control object
  • mkattr - Create control name / control object as a form attribute

AddControls(self, controls, mkattr=True)

 

Adds controls from a dictionary. The dictionary key is the control name and the value is a Form.Control object

Parameters:
  • controls - The control dictionary

CompileEx(self, form)

 

Low level function. Compiles (parses the form syntax and adds the control) the form string and returns the argument list to be passed the argument list to AskUsingForm().

The form controls are wrapped inside curly braces: {ControlName}.

A special operator can be used to return the ID of a given control by its name: {id:ControlName}. This is useful when you use the STARTITEM form keyword to set the initially focused control.

Parameters:
  • form - Compiles the form and returns the arguments needed to be passed to AskUsingForm()

Compile(self)

 

Compiles a form and returns the form object (self) and the argument list. The form object will contain object names corresponding to the form elements

Returns:
It will raise an exception on failure. Otherwise the return value is ignored

Execute(self)

 

Displays a compiled form.

Returns:
1 - ok ; 0 - cancel

EnableField(self, ctrl, enable)

 

Enable or disable an input field

Returns:
False - no such control

ShowField(self, ctrl, show)

 

Show or hide an input field

Returns:
False - no such control

MoveField(self, ctrl, x, y, w, h)

 

Move/resize an input field

Returns:
False - no such fiel

GetFocusedField(self)

 

Get currently focused input field.

Returns:
None if no field is selected otherwise the control ID

SetFocusedField(self, ctrl)

 

Set currently focused input field

Returns:
False - no such control

RefreshField(self, ctrl)

 

Refresh a field

Returns:
False - no such control

GetControlValue(self, ctrl)

 

Returns the control's value depending on its type

Parameters:
  • ctrl - Form control instance
Returns:
  • number: color button, radio controls
  • string: file/dir input, string input and string label
  • int list: for embedded chooser control (0-based indices of selected items)
  • None: on failure

SetControlValue(self, ctrl, value)

 

Set the control's value depending on its type

Parameters:
  • ctrl - Form control instance
  • value -
    • embedded chooser: base a 0-base indices list to select embedded chooser items
Returns:
Boolean true on success

Instance Variable Details

title

The Form title. It will be filled when the form is compiled