Module ida_kernwin :: 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.
  DropdownListControl
Dropdown control This control allows manipulating a dropdown control
  MultiLineTextControl
Multi line text 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.
 
Compiled(self)
Checks if the form has already been compiled
 
Execute(self)
Displays a modal dialog containing the compiled form.
 
Open(self)
Opens a widget containing the 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
 
Close(self, close_normally)
Close the form
 
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__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

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.Choose
  FT_MULTI_LINE_TEXT = 't'
Multi text control - textctrl_info_t
  FT_DROPDOWN_LIST = 'b'
Dropdown list control - Form.DropdownControl
  FT_HTML_LABEL = 'h'
HTML label to display (only for GUI version, and for dynamic labels; no input)
  FT_CHKGRP = 'C'
  FT_CHKGRP2 = 'c'
  FT_RADGRP = 'R'
  FT_RADGRP2 = 'r'
Instance Variables
  form
Form string
  controls
Dictionary of controls
  title
The Form title.
  modal
By default, forms are modal
  openform_flags
If non-modal, these flags will be passed to open_form.
Properties

Inherited from object: __class__

Method Details

__init__(self, form, controls)
(Constructor)

 

Contruct a Form class. This class wraps around ask_form() or open_form() 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 ask_form().

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

A special operator can be used to return the index 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. (note that, technically, the index is not the same as the ID; that's because STARTITEM uses raw, 0-based indexes rather than control IDs to determine the focused widget.)

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

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

Compiled(self)

 

Checks if the form has already been compiled

Returns:
Boolean

Execute(self)

 

Displays a modal dialog containing the 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

Close(self, close_normally)

 

Close the form

Parameters:
  • close_normally - 1: form is closed normally as if the user pressed Enter 0: form is closed abnormally as if the user pressed Esc
Returns:
None

GetControlValue(self, ctrl)

 

Returns the control's value depending on its type

Parameters:
  • ctrl - Form control instance
Returns:
  • color button, radio controls: integer
  • file/dir input, string input and string label: string
  • embedded chooser control (0-based indices of selected items): integer list
  • for multilinetext control: textctrl_info_t
  • dropdown list controls: string (when editable) or index (when readonly)
  • None: on failure

SetControlValue(self, ctrl, value)

 

Set the control's value depending on its type

Parameters:
  • ctrl - Form control instance
  • value -
    • embedded chooser: a 0-base indices list to select embedded chooser items
    • multilinetext: a textctrl_info_t
    • dropdown list: an integer designating the selection index if readonly a string designating the edit control value if not readonly
Returns:
Boolean true on success

Instance Variable Details

title

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

openform_flags

If non-modal, these flags will be passed to open_form. This is an OR'ed combination of the PluginForm.FORM_* values.