Enums
Commands of this submenu are available in the enums window:
All enum members names must be unique in the program. You cannot define more than 256 enum members (symbolic constants) with the same value.
Please note that you can create bitfield definitions here.
You can also add a comment for the enum and for each enum member. In order to specify an enum comment, you must stand at the enum name. Comments are set using regular commands:
See also Edit submenu.
Add/Edit an enum
These commands allow you to define and to edit an enum type. You need to specify:
Each enum has its ID and a serial number. The ID is a number used to refer to the enum, while a serial number is used to order enums during output. Changing the serial number moves the enum to another place.
The serial number of an enum is displayed at the lower left corner of the window.
You can specify any number as a serial number, IDA will move the enum to the specified place.
You also need to specify representation of enum constants. You may choose from various number bases (hex,dec,oct,bin) and character constants.
You may specify the element width or leave it zero. Zero means the element width is not specified. The allowed widths are the powers of 2 in the range of 1..64.
Please note that you can create bitfield definitions here by checking the "bitfield" checkbox.
These command is available when you open the enums window.
See also How to Enter a Number.
Delete an enum type
This command deletes the current enum. Beware, when you delete an enum all references to it will be destroyed. Even if you recreate it later, you'll have to specify again all references to it.
This command is available when you open the enums window.
Define an enum member
This command allows you to define an enum member. An enum member is a symbolic constant. You have to specify its name and value. You cannot define more than 256 constants with the same value in an enum.
If the current enum is a bitfield, you need to specify the bitmask. To learn about bitmasks, read about bitfields.
Edit an enum member
This command allows you to rename an enum member. An enum member is a symbolic constant. Its name must be unique in the program.
To rename an enum type name, position the cursor over the name of the enum.
Delete an enum member
Please remember that deleting a member also deletes all the information about the member, including comments, member name etc.
Bitfields
There is a special kind of enums: bitfields. A bitfield is an enum divided into bit groups. When you define a new symbolic constant in a bitfield, you need to specify the group to which the constant will belong to. By default, IDA proposes groups containing one bit each. If a group is not defined yet, it is automatically created when the first constant in the group is defined. For example:
will define a constant named CONST1 with value 1 and will create a group containing only one bit. Another example. Let's consider the following definitions:
How do we describe this?
If a mask consists of more than one bit, it can have a name and a comment. A mask name can be set when a constant with the mask is being defined. IDA will display the mask names in a different color.
In order to use a bitfield in the program, just convert an instruction operand to enum. IDA will display the operand like this:
will be replaced by
See also Enum window and Bitfields tutorial
Last updated